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

Clarify on_error/on_close behavior #63

Open
moteus opened this issue Mar 6, 2015 · 3 comments
Open

Clarify on_error/on_close behavior #63

moteus opened this issue Mar 6, 2015 · 3 comments

Comments

@moteus
Copy link
Contributor

moteus commented Mar 6, 2015

Async client/server
on_error calls if there some error befor ws handshake done (IO error/SSL handshake/Invalid token/ protocol) . And in this case on_close did not call.
on_close calls if ws handshake done. In case of IO error we call on_close with (false, 1001, "Going away"). And in this caseon_error` did not call.

Is it correct behavior?

@lipp
Copy link
Owner

lipp commented Mar 6, 2015

I think on_close should be called when the client will not be able to work with the ws any more.
You raised one good question: If the connection has never been open, should on_close and on_error be called anyways?

I tend to call on_close and on_error also when the connection failed. This would make async error handling easier.

BTW: on_error should always be calls before on_close. (This is how node.js does it with sockets).

@moteus
Copy link
Contributor Author

moteus commented Mar 6, 2015

May be we should call on_close only if there was on_open event.
And call on_error on any errors.
But there may be cases when other side just close connection and in this case may be we shuld just call on_close with status 1001?

@lipp
Copy link
Owner

lipp commented Mar 6, 2015

ok, agree.

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

No branches or pull requests

2 participants