Git Product home page Git Product logo

connect-mongodb's People

Contributors

blakmatrix avatar cleishm avatar defunctzombie avatar dvv avatar jfromaniello avatar lyhcode avatar masylum avatar raynos avatar sanderpick avatar sethml avatar tedeh avatar treygriffith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connect-mongodb's Issues

Current node v0.5.10-pre doesnt like it

Looks like a version ahead problem.

node -v
v0.5.10-pre

npm install connect-mongodb
npm ERR! Not compatible with your version of node/npm: [email protected]
npm ERR! Required: {"node":">= 0.4.1 < 0.5.0"}
npm ERR! Actual: {"npm":"1.0.100","node":"0.5.10-pre"}

default dbname is invalid.

MongoStore's constuctor options can use "server_config" instead of "db".
but default dbname is "/dev". this is invalid name for mongodb.

https://gist.github.com/1102625

  , _defaults = {host: '127.0.0.1', port: 27017, dbname: '/dev', collection: 'sessions', reapInterval: 60 * 1000};

maybe it's from 0.x, mongodb connnection used "mongodb://host:port" + dbname style URL.

 url += (hosts[i] || hosts[0]) + ':';
 url += ports[i] || ports[0];
 url += options.dbname ? '/' + options.dbname : defaults.dbname;

but now 1.0.x, connect-mongodb doesn't use this URL. so default dbname should "dev" (exclude slash).

TypeError: Object [object Object] has no method 'isConnected'

With the HEAD version of connect-mongodb (https://github.com/masylum/connect-mongodb/commit/fdbe0ff4bf9465f7bfa55f106b2176d3cfd3df79), trying to use it in a replicated mongo setup, I get the following error on app startup:

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Object [object Object] has no method 'isConnected'
    at new MongoStore (/Users/seth/development/service/node_modules/connect-mongodb/lib/connect-mongodb.js:151:21)
    at HTTPServer.<anonymous> (/Users/seth/development/service/app.js:235:12)
    at HTTPServer.configure (/Users/seth/development/service/node_modules/express/lib/http.js:484:52)
    at Object.<anonymous> (/Users/seth/development/service/app.js:219:5)
    at Module._compile (module.js:407:26)
    at Object..js (module.js:413:10)
    at Module.load (module.js:339:31)
    at Function._load (module.js:298:12)
    at Array.<anonymous> (module.js:426:10)
    at EventEmitter._tickCallback (node.js:126:26)

error trying to use sessions with replica sets

hi. i'm trying to use connect-mongodb (and express) with replica sets and authentication but get the following error:

Cannot call method 'findOne' of null
    at MongoStore.get (/home/phil/Dokumente/www/node_modules/connect-mongodb/lib/connect-mongodb.js:95:15)
    at Object.session (as handle)  (/home/phil/Dokumente/www/node_modules/express/node_modules/connect/lib/middleware/session.js:319:11)
    at next (/home/phil/Dokumente/www/node_modules/express/node_modules/connect/lib/http.js:201:15)
    at Object.cookieParser (as handle) (/home/phil/Dokumente/www/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:44:5)
    at next (/home/phil/Dokumente/www/node_modules/express/node_modules/connect/lib/http.js:201:15)
    at Object.methodOverride (as handle) (/home/phil/Dokumente/www/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:35:5)
    at next (/home/phil/Dokumente/www/node_modules/express/node_modules/connect/lib/http.js:201:15)
    at Object.bodyParser (as handle) (/home/phil/Dokumente/www/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:59:61)
    at next (/home/phil/Dokumente/www/node_modules/express/node_modules/connect/lib/http.js:201:15)
    at Object.handle (/home/phil/Dokumente/www/node_modules/express/lib/http.js:84:5)

my code looks like this:

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser());
  app.use(express.session({
    cookie: {maxAge: 60000 * 20}, // 20 minutes
    secret: 'foo',
    store: new mongoStore({
      host: '192.168.2.99',
      port: [27017, 27018, 27019],
      dbname: 'testdb',
      username: 'testdb_user',
      password: 'secret'
    })
  }));
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

any advice?

npm install connect-mongodb failing

I'm running MongoDB 1.8.1, Express 2.3.4, Mongoose 1.3.3 & I am unable to perform npm install connect-mongodb. The output I get is as follows:

> [email protected] install /home/varun/simpleredir/node_modules/connect-mongodb/node_modules/mongodb
> bash ./install.sh

./install.sh: line 2: [: too many arguments
Not building native library for cygwin
make -C ./external-libs/bson
make[1]: Entering directory `/home/varun/simpleredir/node_modules/connect-mongodb/node_modules/mongodb/external-libs/bson'
rm -rf build .lock-wscript bson.node
node-waf configure build
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
'configure' finished successfully (0.079s)
Waf: Entering directory `/home/varun/simpleredir/node_modules/connect-mongodb/node_modules/mongodb/external-libs/bson/build'
[1/9] cxx: bson.cc -> build/default/bson_1.o
[2/9] cxx: long.cc -> build/default/long_1.o
../long.cc: In member function ‘char* Long::toString(int32_t, char*)’:
../long.cc:251: warning: format ‘%lld’ expects type ‘long long int’, but argument 3 has type ‘int64_t’
../long.cc:254: warning: format ‘%llu’ expects type ‘long long unsigned int’, but argument 3 has type ‘int64_t’
../long.cc:258: warning: format ‘%llx’ expects type ‘long long unsigned int’, but argument 3 has type ‘int64_t’
[3/9] cxx: objectid.cc -> build/default/objectid_1.o
[4/9] cxx: binary.cc -> build/default/binary_1.o
[5/9] cxx: code.cc -> build/default/code_1.o
[6/9] cxx: dbref.cc -> build/default/dbref_1.o
[7/9] cxx: timestamp.cc -> build/default/timestamp_1.o
../timestamp.cc: In member function ‘char* Timestamp::toString(int32_t, char*)’:
../timestamp.cc:247: warning: format ‘%lld’ expects type ‘long long int’, but argument 3 has type ‘int64_t’
../timestamp.cc:250: warning: format ‘%llu’ expects type ‘long long unsigned int’, but argument 3 has type ‘int64_t’
../timestamp.cc:254: warning: format ‘%llx’ expects type ‘long long unsigned int’, but argument 3 has type ‘int64_t’
[8/9] cxx: local.cc -> build/default/local_1.o
[9/9] cxx_link: build/default/bson_1.o build/default/long_1.o build/default/objectid_1.o build/default/binary_1.o build/default/code_1.o build/default/dbref_1.o build/default/timestamp_1.o build/default/local_1.o -> build/default/bson.node
Waf: Leaving directory `/home/varun/simpleredir/node_modules/connect-mongodb/node_modules/mongodb/external-libs/bson/build'
'build' finished successfully (7.735s)
=== EXCEUTING TEST_BSON ===
node: ../src/node.cc:1212: ssize_t node::DecodeWrite(char*, size_t, v8::Handle<v8::Value>, node::encoding): Assertion `b[1] == 0' failed.
make[1]: *** [all] Aborted
make[1]: Leaving directory `/home/varun/simpleredir/node_modules/connect-mongodb/node_modules/mongodb/external-libs/bson'
make: *** [build_native] Error 2
npm ERR! error installing [email protected] Error: [email protected] install: `bash ./install.sh`
npm ERR! error installing [email protected] `sh "-c" "bash ./install.sh"` failed with 2
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected]     at ChildProcess.onexit (child_process.js:246:12)
npm ERR! error installing [email protected] Error: [email protected] install: `bash ./install.sh`
npm ERR! error installing [email protected] `sh "-c" "bash ./install.sh"` failed with 2
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected]     at ChildProcess.onexit (child_process.js:246:12)
npm ERR! [email protected] install: `bash ./install.sh`
npm ERR! `sh "-c" "bash ./install.sh"` failed with 2
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the mongodb package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     bash ./install.sh
npm ERR! You can get their info via:
npm ERR!     npm owner ls mongodb
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Linux 2.6.35-28-server
npm ERR! command "node" "/usr/local/bin/npm" "install" "connect-mongodb"
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/varun/simpleredir/npm-debug.log
npm not ok

no method get?

I get this long error out of my app that follows your example pretty closely. (running node v0.2.5)

https://gist.github.com/779266

<script src="https://gist.github.com/779266.js?file=connect-mongodb_error"></script>

the user guide deleted ?

I couldn't find the example, where you show how to use get,set, length methods. Maybe you accidentally deleted ?

Doesn't work with node.js v0.4.9

I just update node to 0.4.9 and when i do this:
app = require('express').createServer(

     express.cookieParser(),
      // Parses x-www-form-urlencoded request bodies (and json)
      express.bodyParser(),
      express.session({ secret: cfg.wiki_session_secret,
            store:new MongoStore({  
                        dbname: 'mydatabase',
                        host: '127.0.0.1',
                        port: 27017
                 })
        })
),

I got this error:

Express
500 TypeError: Cannot call method 'findOne' of null

at MongoStore.get (/usr/local/lib/node/.npm/connect-mongodb/1.0.0beta/package/lib/connect-mongodb.js:96:15)
at Object.session [as handle] (/usr/local/lib/node/.npm/connect/1.5.1/package/lib/middleware/session.js:318:11)
at next (/usr/local/lib/node/.npm/connect/1.5.1/package/lib/http.js:204:15)
at Object.bodyParser [as handle] (/usr/local/lib/node/.npm/connect/1.5.1/package/lib/middleware/bodyParser.js:59:61)
at next (/usr/local/lib/node/.npm/connect/1.5.1/package/lib/http.js:204:15)
at Object.cookieParser [as handle] (/usr/local/lib/node/.npm/connect/1.5.1/package/lib/middleware/cookieParser.js:44:5)
at next (/usr/local/lib/node/.npm/connect/1.5.1/package/lib/http.js:204:15)
at Object.handle (/usr/local/lib/node/.npm/express/2.4.0/package/lib/http.js:85:5)
at next (/usr/local/lib/node/.npm/connect/1.5.1/package/lib/http.js:204:15)
at HTTPServer.handle (/usr/local/lib/node/.npm/connect/1.5.1/package/lib/http.js:217:3)

I think it doesn't work for v0.4.9

How to clean up the database?

Hi, I can see that in every visits, there will be a new record stored in the database, would those records delete itself or I have to do it? If I have to do it, how could I?

why there are two expires

{ "_id" : "na11Ioshb86v5nKRl7WMlVzn.TZypW4Zn6IWUQQ8tUK0k73H3VWqCXhzTq5wii+ssue4", 
"session" : "{\"lastAccess\":1306946645365,\
"cookie\":{\"originalMaxAge\":2592000,\"expires\":\"2011-06-01T17:27:17.369Z\",\"httpOnly\":true,\"path\":\"/\"},\"username\":\"forestgumb\"}", 
"expires" : NumberLong("1306949237000") }

That's a record in collection sessions in database chat. You can see there are two expires, the first expries is "2011-06-01T17:27:17.369Z", 30 days from this date, which is exactly what I set in mongo_store configure. The second one is 1306949237000, which is 15-Jul-2010 2: 30pm, only 15 days from this date.

which one of those expires determine the expiration of the session in database ?

Using connect-mongodb on Windows

I would love to store sessions in MongoDB using connect-mongodb. Sadly it keeps telling me that it is not supported on Windows when I try to install it via npm. It's dependencies Node.js, MongoDB and connect all work fine on Windows, so that can't be the barrier, can it?

You will probably hate me for using this OS, but I'll ask anyway. ^_^ Is there a way to install it manually? It would be so sad if I ought to miss connect-mongodb. Here is what the console sais:

D:\projects\node>npm install connect-mongodb
npm http GET https://registry.npmjs.org/connect-mongodb
npm http 304 https://registry.npmjs.org/connect-mongodb
npm http GET https://registry.npmjs.org/connect/1.8.5
npm http GET https://registry.npmjs.org/mongodb/0.9.7
npm http 304 https://registry.npmjs.org/connect/1.8.5
npm http 304 https://registry.npmjs.org/mongodb/0.9.7
npm ERR! error rolling back [email protected] Error: ENOTEMPTY, rmdir 'D:\projects\node\node_modules\connect-mongodb'

npm ERR! Unsupported
npm ERR! Not compatible with your operating system or architecture: [email protected]
npm ERR! Valid OS:    linux,darwin,freebsd
npm ERR! Valid Arch:  any
npm ERR! Actual OS:   win32
npm ERR! Actual Arch: ia32
npm ERR!
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files(x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "connect-mongodb"

npm ERR! cwd D:\projects\node
npm ERR! node -v v0.6.15
npm ERR! npm -v 1.1.16
npm ERR! code EBADPLATFORM
npm ERR! message Unsupported
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     D:\projects\node\npm-debug.log
npm not ok

License?

Is connect-mongodb licensed? If so, under what license? I need to provide this information for any and all npm modules I use.

looking for the 'sessions' collection

I'm looking for the 'sessions' collection. Everything works perfect, yet I fail to find that collection. I suspect some caching mechanism. Should I .save() in order to see the collection?

Can you please write something about it in the readme, or add an example.

A lot of thanks,

Oren

search monge_store using value different from sessionId

I store usernames in the mongo_store, and I want to retrieve session using username instead of sessionId, look like it doesn't work that way?

My data scheme:

{ lastAccess: { low_: 1896901905, high_: 304 },
  cookie: 
   { path: '/',
     httpOnly: true,
     _expires: Fri, 08 Jul 2011 21:02:44 GMT,
     originalMaxAge: { low_: -1702967296, high_: 0 } },
  ioid: '8401068514212966',
  channel: 'all',
  username: 'xuka' }

nodejs code

    <pre>mongo_store.get(SessionId, function(err, session) {
        //results
    });

    mongo_store.get(username, function(err, session) {
        //no result
    });</pre>

bash ./install.sh

I receive the following error installing connect-mongodb:

Failed at the [email protected] install script
Fails on: bash ./install.sh

I am running node 0.6.7 on windows

TypeError: Cannot read property 'Store' of undefined

I've googled this and even searched the closed issues here on github, but I can't find anyone with this problem.

I'm using node.js v0.4.9 (The version from the ubuntu repositories) and connect v1.8.5 that I grabbed from npm. I also grabbeb connect-mongodb from npm.

Every time I require('connect-mongodb') I get an exception stating :
TypeError: Cannot read property 'Store' of undefined

This point to the first line of connect-mongodb.js that reads :
var Store = require('connect').session.Store

Is this an incompatibility issue or something?
If you need more informations, let me know.

Error installing connect-mongodb

I'm getting this error while trying to install connect-mongodb

npm install connect-mongodb

npm ERR! error installing [email protected] Error: shasum check failed for /var/folders/kx/lq9mryjn1qsd84kzy9wy9fz80000gn/T/npm-1318079623785/1318079623803-0.30375908222049475/tmp.tgz
npm ERR! error installing [email protected] Expected: 1061dbf18f5f4a00f6da52a0c9eab11e70620bfc
npm ERR! error installing [email protected] Actual: c3d6a2bec2379bf568ba0b2ae495b093dae5f85c
npm ERR! error installing [email protected] at /usr/local/lib/node_modules/npm/lib/utils/sha.js:25:20
npm ERR! error installing [email protected] at [object Object]. (/usr/local/lib/node_modules/npm/lib/utils/sha.js:49:5)
npm ERR! error installing [email protected] at [object Object].emit (events.js:61:17)
npm ERR! error installing [email protected] at afterRead (fs.js:878:12)
npm ERR! error installing [email protected] at wrapper (fs.js:245:17)
npm ERR! Error: shasum check failed for /var/folders/kx/lq9mryjn1qsd84kzy9wy9fz80000gn/T/npm-1318079623785/1318079623803-0.30375908222049475/tmp.tgz
npm ERR! Expected: 1061dbf18f5f4a00f6da52a0c9eab11e70620bfc
npm ERR! Actual: c3d6a2bec2379bf568ba0b2ae495b093dae5f85c
npm ERR! at /usr/local/lib/node_modules/npm/lib/utils/sha.js:25:20
npm ERR! at [object Object]. (/usr/local/lib/node_modules/npm/lib/utils/sha.js:49:5)
npm ERR! at [object Object].emit (events.js:61:17)
npm ERR! at afterRead (fs.js:878:12)
npm ERR! at wrapper (fs.js:245:17)
npm ERR! Report this entire log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]
npm ERR!
npm ERR! System Darwin 11.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "connect-mongodb"
npm ERR! cwd /Volumes/work/Projects/NodeApps/madblog
npm ERR! node -v v0.4.11
npm ERR! npm -v 1.0.30
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Volumes/work/Projects/NodeApps/madblog/npm-debug.log
npm not ok

TypeError going to www only

Hi there,

When I go to www.server.com instead of server.com, Express dumps with this:

Express
500 TypeError: Cannot call method 'toString' of undefined
at /home/peerbii/lib/node/.npm/connect-mongodb/0.2.2/package/lib/connect-mongodb.js:136:44
at [object Object]. (/home/.../lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/collection.js:448:35)
at [object Object].emit (events.js:67:17)
at [object Object]. (/home/.../lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/db.js:90:12)
at [object Object].emit (events.js:64:17)
at Socket. (/home/.../lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/connection.js:82:16)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:665:31)
at IOWatcher.onReadable [as callback] (net.js:177:10)

Line 136 of connect-mongodb.js is

      cb(null, JSON.parse(data.session.toString()));

Any ideas?

Thanks

Keeping getting this error if tried to access from external IP

TypeError: Cannot read property 'expires' of undefined
at MongoStore.createSession (/node_modules/connect/lib/middleware/session/store.js:51:28)
at /node_modules/express/node_modules/connect/lib/middleware/session.js:340:15
at /node_modules/connect-mongodb/lib/connect-mongodb.js:161:9
at [object Object]. (/node_modules/connect-mongodb/node_modules/mongodb/lib/mongodb/collection.js:669:5)
at [object Object].emit (events.js:67:17)
at [object Object]. (/node_modules/connect-mongodb/node_modules/mongodb/lib/mongodb/connections/server.js:78:12)
at [object Object].emit (events.js:64:17)
at Socket. (/node_modules/connect-mongodb/node_modules/mongodb/lib/mongodb/connection.js:89:16)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:673:31)

And this one :

SyntaxError: Unexpected token ILLEGAL
at Object.parse (native)
at /var/www/TGV/node_modules/connect-mongodb/lib/connect-mongodb.js:133:23
at [object Object]. (/var/www/TGV/node_modules/connect-mongodb/node_modules/mongodb/lib/mongodb/collection.js:764:5)
at [object Object].emit (events.js:67:17)
at [object Object]. (/var/www/TGV/node_modules/connect-mongodb/node_modules/mongodb/lib/mongodb/connections/server.js:88:12)
at [object Object].emit (events.js:64:17)
at Socket. (/var/www/TGV/node_modules/connect-mongodb/node_modules/mongodb/lib/mongodb/connection.js:94:16)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:673:31)
at IOWatcher.onReadable as callback

trouble with req.sessionStore

hello mates what's up

ok sessions are set, everything works fine, when i call a page i get a new raw in database, i can also add attributes like so

req.session.myuser = 'myname'

my problem is that req.sessionStore is empty
when i dump it all i got is

{ generate: [Function] }

i'm suposed to have all prototyped function clear, length etc

why is that ?

i'm using express 3.0.0rc2

here is my app.js

var mongoStore= require('connect-mongodb')
app.use(express.logger())
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.cookieParser())
app.use(express.session({ cookie: {maxAge: 60000 * 10}, secret: "secretkey", store: new mongoStore({ db: mongo.con.db, reapInterval: 15000 }) })) //check every 5 seconds with a 2 minutes expire time
app.use(app.router)


app.get('/mypage', function(req, res){

   console.log(req.sessionStore) // return { generate: [Function] }

  o = {}
  for(var i in req.sessionStore) o[i] = i
  res.json(o) // return prototyped object (with length, clear, destroy etc )
   //but accessing them don't work because they are null

})}

notice that if i change

for(var i in req.sessionStore) o[i] = i
//with
for(var i in req.sessionStore) o[i] = req.sessionStore[i]

than res.json(o) will be equal to {}

:( any idea ??

Unexpected token ILLEGAL

Hi there,

I've upgrade to node 0.4.3 today, and with it lots of packages via npm. I made some minor code tweaks to make sure that Mongoose's models are defined properly, but that's about it.

Now, upon running the server and attempting a connection, I get this:

SyntaxError: Unexpected token ILLEGAL
at Object.parse (native)
at /usr/local/lib/node/.npm/connect-mongodb/0.2.1/package/lib/connect-mongodb.js:138:25
at [object Object].<anonymous> (/usr/local/lib/node/.npm/mongodb/0.9.1/package/lib/mongodb/collection.js:447:35)
at [object Object].emit (events.js:67:17)
at [object Object].<anonymous> (/usr/local/lib/node/.npm/mongodb/0.9.1/package/lib/mongodb/db.js:83:12)
at [object Object].emit (events.js:64:17)
at Socket.<anonymous> (/usr/local/lib/node/.npm/mongodb/0.9.1/package/lib/mongodb/connection.js:82:16)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:665:31)
at IOWatcher.onReadable [as callback] (net.js:177:10)

Also, if i just leave the server running, I'll eventually get this error:

 21 Mar 00:00:51 - [ERROR] TypeError

/usr/local/lib/node/.npm/connect-mongodb/0.2.1/package/lib/connect-mongodb.js:104
  _collection.remove({expires: {'$lte': Date.now()}}, function () { });
              ^
TypeError: Cannot call method 'remove' of null  
at Timer.<anonymous> (/usr/local/lib/node/.npm/connect-mongodb/0.2.1/package/lib/connect-mongodb.js:104:19)
at Timer.callback (timers.js:208:16)

Any idea what's up with this?

Thanks!
Paul

Session#touch

As documented here:
http://senchalabs.github.com/connect/middleware-session.html

Is it possible it's not working with your session store? I'm not sure if it's me or the library here though...

I'm trying to keep the session alive as long as the websocket connection is alive... so I'd like to touch the session everytime I receive a message or send one with socket.io.

To gather the session within socket.io, I take the request's session and fetch it with your session store. Once I got it, I tried to touch it, I got an undefined method...

Am I using the right object here? Appreciate any help on the matter! Thanks.

Not working with latest connect version (1.x)

getting this error

Error: TypeError: Cannot set property data of #<Object> which has only a getter
    at Object.merge (/home/narf/as_tools/usr/local/lib/node/.npm/connect/1.0.3/package/lib/utils.js:55:14)
    at Object.Cookie (/home/narf/as_tools/usr/local/lib/node/.npm/connect/1.0.3/package/lib/middleware/session/cookie.js:26:22)
    at /home/narf/as_tools/usr/local/lib/node/.npm/connect/1.0.3/package/lib/middleware/session.js:316:23
    at /home/narf/as_tools/usr/local/lib/node/.npm/connect-mongodb/0.1.1/package/lib/connect-mongodb.js:133:9
    at [object Object].<anonymous> (/home/narf/as_tools/usr/local/lib/node/.npm/mongodb/0.9.1/package/lib/mongodb/collection.js:447:35)
    at [object Object].emit (events.js:45:17)
    at [object Object].<anonymous> (/home/narf/as_tools/usr/local/lib/node/.npm/mongodb/0.9.1/package/lib/mongodb/db.js:83:12)
    at [object Object].emit (events.js:42:17)
    at Socket.<anonymous> (/home/narf/as_tools/usr/local/lib/node/.npm/mongodb/0.9.1/package/lib/mongodb/connection.js:82:16)
    at Socket.emit (events.js:42:17)

no method toUTCString

I was on 0.3.0 and just updated to connect 1.5.2 and connect-mongodb 0.4.0

I'm getting this error:

    /Users/aaa/proj/node_modules/connect-mongodb/node_modules/connect/lib/utils.js:171

      if (obj.expires) pairs.push('expires=' + obj.expires.toUTCString());



                         ^


    TypeError: Object 5184000000 has no method 'toUTCString'
        at Object.serializeCookie (/Users/aaa/proj/node_modules/connect-mongodb/node_modules/connect/lib/utils.js:171:56)
        at Object.serialize (/Users/aaa/proj/node_modules/connect-mongodb/node_modules/connect/lib/middleware/session/cookie.js:113:18)
        at ServerResponse.writeHead (/Users/aaa/proj/node_modules/express/node_modules/connect/lib/middleware/session.js:264:46)
        at ServerResponse._implicitHeader (http.js:787:8)
        at ServerResponse.end (http.js:651:10)
        at next (/Users/aaa/proj/node_modules/express/node_modules/connect/lib/http.js:169:13)
        at /Users/aaa/proj/node_modules/express/node_modules/connect/lib/middleware/session.js:322:9
        at /Users/aaa/proj/node_modules/express/node_modules/connect/lib/middleware/session.js:322:9
        at /Users/aaa/proj/node_modules/express/node_modules/connect/lib/middleware/session.js:332:11
        at /Users/aaa/proj/node_modules/connect-mongodb/lib/connect-mongodb.js:166:7

Reverting back to 0.3.0 for now.

Feature request: Allow initialization via a mongo path string instead of options object

I prefer to store my mongo database path in an environment variable, so that it can be different on the production and dev servers. The require('mongodb').connect function can simply take a string specifying the full path to a database, so it would be convenient if I could pass the same string to connect-mongo instead of an options object. Internally, there is already a function to parse such a string (parseConnectionURL), so it should be a simple fix.

Suggestion.

Anybody (apart from me) ever seen a need for the following optional functionality 'afterReap' see here in

https://github.com/daithiw44/connect-mongodb#afterreap

afterReap: is an optional function passed in as an argument to return the sessionID's removed in the current reap of dead sessionID's.

Use case : I was using it where I had a sessionID and I was storing the ID against other collections and not against the session data as such and when the user left I'd want to know to clean up their footprints.

Just a suggestion if anyone thinks it might be worth having, else I'm happy to exist in my own version of my world.

given _id

Hi,

Is it possible to (re)generate a session with a _id given?

Thanks,
Philippe

can not call method foreach of undefined

this happens periodically every 10-20 minutes. The errors:

/usr/local/lib/node/.npm/mongodb/0.9.3/package/lib/mongodb/db.js:624
dbcopy.serverConfig.servers.forEach(function(server) {
^
TypeError: Cannot call method 'forEach' of undefined
at [object Object].checkMaster_ (/usr/local/lib/node/.npm/mongodb/0.9.3/package/lib/mongodb/db.js:624:31)
at [object Object].executeCommand (/usr/local/lib/node/.npm/mongodb/0.9.3/package/lib/mongodb/db.js:569:12)
at [object Object].findOne (/usr/local/lib/node/.npm/mongodb/0.9.3/package/lib/mongodb/collection.js:456:11)
at MongoStore.get (/usr/local/lib/node/.npm/connect-mongodb/0.3.0/package/lib/connect-mongodb.js:130:15)
at [object Object]. (/var/www/html/nodejs/server.js:69:15)
at [object Object].emit (events.js:64:17)
at [object Object]._onMessage (/usr/local/lib/node/.npm/socket.io/0.6.17/package/lib/socket.io/client.js:58:10)
at Parser. (native)
at Parser.emit (events.js:64:17)
at Parser.parse (/usr/local/lib/node/.npm/socket.io/0.6.17/package/lib/socket.io/transports/websocket.js:195:12)
[root@localhost nodejs]#

This issue will crash mongoDB and nodejs server at the same time. below is the code, that the error might be talking about

socket.on('connection', function(client) {
    client.on('message', function(message) {
        //line69 is here
        mongo_store.get(message.chatSessionId, function(err, session) {
            //console.log(message.chatSessionId);
            console.log(message.text);
            //console.log(session);
            if (err || !session) {
                client.send('Your chat session has been expired. Try reload the page');
                return;
            }
            else if(message.username === session.username){             
                socket.broadcast(message.username+': '+ wordFilter(message.text));
            }
        });
    });
});

TypeError: Cannot call method 'remove' of null when trying init connection

You should apply this changes in lib/connect-mongodb.js file

new
... @@ -44,6 +44,16 @@ var MONGOSTORE = module.exports = function MongoStore(options, callback) {
44 } else {
45 getCollection(db, callback);
46 }
47 +
48 + if (options.reapInterval !== -1) {
49 + var reap_interval = setInterval(function () {
50 + _collection.remove({expires: {'$lte': Date.now()}}, function () { });
51 + }, options.reapInterval || _defaults.reapInterval, this); // _defaults to each minute
52 +
53 + db.on('close', function () {
54 + clearInterval(reap_interval);
55 + });
56 + }
57 }
58
59 if (options.url) {
... @@ -77,16 +87,6 @@ var MONGOSTORE = module.exports = function MongoStore(options, callback) {
87
88 Store.call(this, options);
89
- if (options.reapInterval !== -1) {
- var reap_interval = setInterval(function () {
- _collection.remove({expires: {'$lte': Date.now()}}, function () { });
- }, options.reapInterval || _defaults.reapInterval, this); // _defaults to each minute
-
- db.on('close', function () {
- clearInterval(reap_interval);
- });
- }
-
90 if (server_config.isConnected()) {
91 authenticateAndGetCollection(callback);

Database Connection URI Support

Can you make connect-mongodb support database connection URIs like mongoose?

It'll simplify configuration for apps that use mongoose already.

Why stringify?

You stringify the session before storing it. This makes it difficult to query in mongo, mongo can handle json. What am I missing? Thanks.

Cannot call method 'findOne' of undefined

Hello, please help me with this problem
my code:
app.use(express.session({
secret: 'keyboard cat',
cookie: { maxAge: 60_60_2 },
store: new mongoStore( { db:db } )
}));
and when i call:
db.users.findOne()
i have this error
then i call
db.users
i get - undefined
thank you.

After upgrading to Express 2.3.2 receiving error

After I upgraded to Express to 2.3.2 (which also upgrades Connect to 1.4.0) I am now receiving an error when trying to use connect-mongodb for my session store. If I switch back to Express 2.2.2 I don't have any issues:

TypeError: Object # has no method 'createSession'
at /usr/local/lib/node/.npm/connect/1.4.0/package/lib/middleware/session.js:324:15
at /usr/local/lib/node/.npm/connect-mongodb/0.2.2/package/lib/connect-mongodb.js:136:11
at [object Object]. (/usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/collection.js:448:35)
at [object Object].emit (events.js:67:17)
at [object Object]. (/usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/db.js:90:12)
at [object Object].emit (events.js:64:17)
at Socket. (/usr/local/lib/node/.npm/mongodb/0.9.2/package/lib/mongodb/connection.js:82:16)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:665:31)
at IOWatcher.onReadable as callback

My app.js looks like this:

var mongoStore = require('connect-mongodb');
app.set('db-uri', 'mongodb://localhost/questions');
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({
secret: 'hi',
store: new mongoStore({url: app.set('db-uri')})
}));
app.use(express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time ms' }))
app.use(app.router)
app.use(express.static(__dirname + '/public'));
});

dependencies to mongodb 0.9.7 build failed on Win32 platform

mongodb 0.9.7 dependency break the "npm install connect-mongodb" installation on win32 platform.
newer mongodb like 1.0.2 will fix this problem
thanks

npm ERR! error rolling back [email protected] Error: ENOTEMPTY, rmdir 'C:\AC
AD_TAJ\node_modules\connect-mongodb'

npm ERR! Unsupported
npm ERR! Not compatible with your operating system or architecture: [email protected]
npm ERR! Valid OS: linux,darwin,freebsd
npm ERR! Valid Arch: any
npm ERR! Actual OS: win32
npm ERR! Actual Arch: ia32
npm ERR!
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! cwd C:\ACAD_TAJ
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.21
npm ERR! code EBADPLATFORM
npm ERR! message Unsupported
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\ACAD_TAJ\npm-debug.log
npm not ok

Seems to be broken with mongodb client 0.9.7

With a quite basic/default setup i get this appon the first connection.
can somebody verify?

/home/cryptix/node_modules/connect-mongodb/lib/connect-mongodb.js:81
      _collection.remove({expires: {'$lte': Date.now()}}, function () { });
                  ^
TypeError: Cannot call method 'remove' of null
    at Timer.<anonymous> (/home/cryptix/node_modules/connect-mongodb/lib/connect-mongodb.js:81:19)
    at Timer.ontimeout (timers.js:203:14)

Plans for 0.7.x/0.8.x branch?

The dependencies included (mongodb and connect) are both too old for the 0.8 branch. Any plans on making this 0.8-compliant?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.