SocketException handling request, closing client connection: 9001 socket exception

1,217 views
Skip to first unread message

Drew Foehn

unread,
Mar 14, 2012, 9:38:41 PM3/14/12
to node-mongodb-native
Hi,

I'm new to mongo and node-mongodb-native.

I'm unsure as to whether or not this is the correct way to go about
things, but I've written about 5 mapReduce queries that run every time
a user connects to an express endpoint. I have only 48 records in my
set and no indexes. One user hitting the service seems fine but when I
test 10 current users the app dies straight away with this stack
trace:

node.js:201
throw e; // process.nextTick error, or 'error' event on first
tick
^
TypeError: Cannot read property 'callback' of null
at [object Object].<anonymous> (/Sites/rf.dev/src/node_modules/
mongodb/lib/mongodb/connection/server.js:280:24)
at [object Object].emit (events.js:67:17)
at [object Object].<anonymous> (/Sites/rf.dev/src/node_modules/
mongodb/lib/mongodb/connection/connection_pool.js:154:13)
at [object Object].emit (events.js:70:17)
at Socket.<anonymous> (/Sites/rf.dev/src/node_modules/mongodb/lib/
mongodb/connection/connection.js:330:22)
at Socket.emit (events.js:67:17)
at TCP.onread (net.js:347:14)

I'm using mongodb 0.9.9-4 and v0.6.7 and mongo v2.0.2

Here is an example of one of the calls:

_this.db.open(function(err, db) {

db.createCollection('something', function(err, col) {

col.mapReduce(map, reduce, {'out': 'tmp', 'query':
{'shortName' : category}}, function(err, collection) {


collection.find().sort({"value.checkins":-1}).limit(1).nextObject(function(err,
doc){

//do something

});
});
});
});

All 5 of these calls run in parallel using the async library. Should I
not be doing it this way? Should I be caching the results and using
the cached results?

Cheers,

Drew Foehn

unread,
Mar 17, 2012, 5:06:43 PM3/17/12
to node-mong...@googlegroups.com
So I solved the issue.

I think it's been mentioned here before but only call "open" once in your application... Seems obvious now...

christkv

unread,
Mar 18, 2012, 4:23:19 AM3/18/12
to node-mongodb-native
I've made the latest driver version throw if it happens so that it
will be easier to avoid this mistake in the future :)
Reply all
Reply to author
Forward
0 new messages