postwait / node-amqp

[UNMAINTAINED] node-amqp is an AMQP client for nodejs
MIT License
1.69k stars 357 forks source link

Fixed exponential reconnect not waiting twice as much each time #217

Closed bakkerthehacker closed 11 years ago

bakkerthehacker commented 11 years ago

Fixed exponential reconnect not wait twice as much. Moved possibleAuthErrorHandler to addAllListeners. Fixed reconnect removing all externally added events.

bakkerthehacker commented 11 years ago

Any update on this?

bcjwilson commented 11 years ago

Post merge, still seeing memory leak problem due to reconnect event handlers.

bcjwilson commented 11 years ago

Belay that, working locally. How do we get this out to npm?

bakkerthehacker commented 11 years ago

I'm assuming that postwait or someone else will decide that the code is stable enough and that enough new features have been merged in, rev the code, and push to npm.

bcjwilson commented 11 years ago

Thanks for fixing that. I'm now seeing a new problem, not sure whether this is expected behavior.

Example code:

  // not running RabbitMQ locally
  var connection = amqp.createConnection();

  connection.on('error', function(err){
    console.log("ERROR: " + err.message);
  });

Output (one second between each line):

ERROR: connect ECONNREFUSED
ERROR: connect EADDRNOTAVAIL
ERROR: connect EADDRNOTAVAIL
...
ERROR: connect EADDRNOTAVAIL

The first connection attempt is refused, after that it's address not available. Shouldn't they all be connection refused?

bakkerthehacker commented 11 years ago

i could look into it

bcjwilson commented 11 years ago

Thanks, I'm not yet familiar enough with the amqp source to make a suggestion. The little research I've done suggests that EADDRNOTAVAIL means you're trying to bind a socket that's already bound. But connecting from a client-side app shouldn't have to do that, right?

Maybe it has to do with keeping the old connection around?

Side question: Is there a way to turn off the reconnect logic from client code? When RabbitMQ dies, I have to rebuild the world on the client side anyway (reestablish transient exchanges, make a new queue etc.) So I'd kinda like to just do the reconnecting myself.

bakkerthehacker commented 11 years ago

https://github.com/postwait/node-amqp#connection-options-and-url

bcjwilson commented 11 years ago

Thanks, that's just what I needed - also, looks like the patch made it to npm :)