1

Im recieving the following error in Node.js, I believe that it is related to AMQP.

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at Connection.EventEmitter.addListener (events.js:160:15)
    at Connection.EventEmitter.once (events.js:179:8)
    at Connection.connect (/var/www/project/app/node_modules/amqp/amqp.js:1084:8)
    at Connection.reconnect (/var/www/project/app/node_modules/amqp/amqp.js:1049:8)
    at null._onTimeout (/var/www/project/app/node_modules/amqp/amqp.js:886:16)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Can anyone point at what the issue may be?

Heres the code from my module that I use to connect:

JackRabbit.prototype.subscribe = function subscribe(recievedCB, routingKey) {
    var self = this;
    var route = routingKey || '#';

    self.createConnection(function(rabbitMq, ex, q) {
        // Catch all messages
        q.bind(self.config.exchangeName, route);

        // Receive messages
        q.subscribe(self.config.messageOptions, function(msg, headers, deliveryInfo) {            
            recievedCB(q, msg, headers, deliveryInfo);

            // Clsoe connection
            //rabbitMq.end();
        });        
    });
}

And here is where I call that method:

var scrapRequestRecieved = function(q, msg, headers, deliveryInfo) {
    console.log("SC msg: %j", msg);

    /** Callback function shifts the completed job from the queue. */
    phantom.scrapeUrls(msg.urls, function() {
        console.log("SC DONE");
        q.shift();
    });
};
rabbit.subscribe(scrapRequestRecieved, "sc.#");
RachelD
  • 4,072
  • 9
  • 40
  • 68

2 Answers2

2

After some searching, it appears the problem is caused by AMPQ's old connection logic. Every time a reconnect was attempted, a new listener would be added without the old one being removed. The issue has since been fixed in this pull request.

hexacyanide
  • 88,222
  • 31
  • 159
  • 162
  • I'm pretty sure I have the latest and greatest version of node-amqp however I see that they added much better docs to their readme file so I'm scowering their github for something I've done wrong. Thank you! – RachelD Sep 13 '13 at 16:27
  • You can also check the files in `node_modules` to see if the module you have installed has a certain patch installed. – hexacyanide Sep 13 '13 at 16:49
  • What I ended up doing was restarting the rabbitmq service. I had changed the port that it was running on and I think that threw it out of wack. It did make me notice a typo that was not setting something that should be set but that was a queue miss-configuration. – RachelD Sep 13 '13 at 18:05
1

The last version 0.1.8 has included the pull request remarked by @hexacyanide.

jgato
  • 181
  • 1
  • 6