Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanly disconnect from the server with disconnect() #295

Merged
merged 1 commit into from
Mar 12, 2014

Conversation

glenjamin
Copy link
Contributor

Sends connection.close, and waits for a connection.close-ok before
closing the socket.

connection.end() will still work for backwards compatibility by closing
the underlying socket, but is removed from the documentation.

I'm unsure whether I should have done more work around making sure to blackhole any messages received after sending the connection.close to properly follow the spec[1], or to shut down the object state of the channels and things.

As this is only new behaviour it should be perfectly safe to add regardless.

[1] https://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.close

Sends connection.close, and waits for a connection.close-ok before
closing the socket.

connection.end() will still work for backwards compatibility by closing
the underlying socket, but is removed from the documentation.
@cmoesel
Copy link
Contributor

cmoesel commented Jan 21, 2014

My pull request #248 also addresses the clean disconnect problem, but I chose to integrate it into connection.end, rather than create a new function. I do like that your pull request allows previous functionality to remain exactly the same though.

In my testing I discovered that it is important to ignore any received messages (except connectionClose and connectionCloseOk) after you've sent the connection close message, otherwise some errors can occur. So, it's not just a matter of following the spec, but does actually affect real behavior and stability. You can see my pull request for an example of how I chose to do this.

Also-- a word of advice-- the maintainers of this library are unlikely to merge your request if it does not contain any unit tests, so you can improve your chances by adding tests as well. That said, they haven't accepted my pull requests either, so who am I to be giving advice? ;-)

@glenjamin
Copy link
Contributor Author

Ah, I had a go at finding an existing PR but must have missed that one.

I'll probably flesh this out like you suggest so both options are available to merge - cheers for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants