jdarling / MongoMQ

MongoMQ is a messaging queue built on top of Node.js and MongoDB's tailable cursors.
MIT License
90 stars 20 forks source link

[Error: Connection was destroyed by application] #16

Closed rafalsobota closed 11 years ago

rafalsobota commented 11 years ago

I try to run any example of MongoMQ without success. My simple queue watcher:

var MC, MQ, mq, options;

MC = require('mongomq').MongoConnection;

MQ = require('mongomq').MongoMQ;

options = {
  host: 'localhost',
  databaseName: 'mongomq',
  queueCollection: 'queue',
  autoStart: false
};

mq = new MQ(options);

mq.on('push', function(error, data, next) {
  if (error) {
    console.log('error', error);
    return next();
  }
  console.log('handling push', data);
  return next();
});

mq.ready(function() {
  return console.log('ready');
});

mq.start(function(error) {
  if (error) {
    return console.log('error during start of MongoMQ', error);
  }
});

I run this code with node v0.8.20 and mongodb 2.3. I've created local database 'mongomq' and capped collection 'queue' inside.

mongo mongomq
> db.createCollection("queue", {capped:true, size:100000})
{ "ok" : 1 }

I've installed mongomq from npm. When I run this file I got

error during start of MongoMQ [Error: Connection was destroyed by application]

Am I doing something wrong? Cheers.

rafalsobota commented 11 years ago

The same with your examples/basic/app.js:

> node app.js 
Emitting: 0

ERROR:  
/Users/rafal/Sources/MongoMQ/node_modules/mongodb/lib/mongodb/connection/server.js:562
        throw err;
              ^

ERROR:  Error: Connection was destroyed by application
    at Db._executeInsertCommand (/Users/rafal/Sources/MongoMQ/node_modules/mongodb/lib/mongodb/db.js:1752:55)
    at insertAll (/Users/rafal/Sources/MongoMQ/node_modules/mongodb/lib/mongodb/collection.js:330:13)
    at Collection.insert (/Users/rafal/Sources/MongoMQ/node_modules/mongodb/lib/mongodb/collection.js:92:3)
    at MongoMQ.emit (/Users/rafal/Sources/MongoMQ/lib/MongoMQ.js:149:18)
    at Db.collection (/Users/rafal/Sources/MongoMQ/node_modules/mongodb/lib/mongodb/db.js:462:44)
    at MongoConnection.collection (/Users/rafal/Sources/MongoMQ/lib/MongoConnection.js:230:15)
    at MongoMQ.checkConnection (/Users/rafal/Sources/MongoMQ/lib/MongoMQ.js:59:5)
    at MongoConnection.collection (/Users/rafal/Sources/MongoMQ/lib/MongoConnection.js:228:8)
    at MongoMQ.emit (/Users/rafal/Sources/MongoMQ/lib/MongoMQ.js:131:10)
    at MongoMQ.checkConnection (/Users/rafal/Sources/MongoMQ/lib/MongoMQ.js:59:5)

undefined
undefined
[Error: Connection was destroyed by application]

undefined
undefined
jdarling commented 11 years ago

Interesting. Let me see of some of the dependencies have changed some place. This may be a versioning issue some place. It should work just fine though.

jdarling commented 11 years ago

This appears to be a difference between 1.3.6 and 1.2.8 in the MongoDB Node Native driver. A work around (at least till I patch this up) is to force 1.2.8 using "npm install mongodb@1.2.8"

I'll start digging around the 1.3.6 documentation to see what changes I need to make with MongoMQ and will be locking down the versions of the dependencies with the next release.

rafalsobota commented 11 years ago

Awesome! Thanks for response

On Tue, May 28, 2013 at 6:10 PM, jdarling notifications@github.com wrote:

This appears to be a difference between 1.3.6 and 1.2.8 in the MongoDB Node Native driver. A work around (at least till I patch this up) is to force 1.2.8 using "npm install mongodb@1.2.8"

I'll start digging around the 1.3.6 documentation to see what changes I need to make with MongoMQ and will be locking down the versions of the dependencies with the next release.

Reply to this email directly or view it on GitHub: https://github.com/jdarling/MongoMQ/issues/16#issuecomment-18561270

jdarling commented 11 years ago

The fix was easy enough, remove a close from the use statement. Pushed version 1.3.2 of MongoMQ to resolve this. Locked the dependency chain down, and fixed a minor bug in lib.js.

Let me know if this doesn't fix the issue for you.