postwait / node-amqp

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

Connection.End Causes a "Ready" Function to Be Fired #354

Closed dchankhour closed 10 years ago

dchankhour commented 10 years ago

I have a situation where i'm going to be creating multiple connections to Rabbit. But i'm try to be smart about the connections and try to remove them if there are no need for it. However, it seems that when i try to do a conn.disconnect(), the connection actually closes but it reconnects and the conn.on("ready") function is fired back.

Is there a better way to disconnect the TCP connection.

dchankhour commented 10 years ago

I was able to solve the issue by using conn.destroy() but i had to revert to an older version. it seems that the new version has an issue with disconnect().

mcasimir commented 8 years ago

Same issue, can u reopen/explain what is the right way to completely close a connection?

Amberlamps commented 8 years ago

connection.disconnect() triggers a ECONNRESET error and immediately tries to reconnect. Therefore the ready event is emitted. In order to disconnect from amqp, I needed to call connection.destroy() as well.

Why is this not in the documentation and why is connection.disconnect() not working?