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

error handling on websocket connect #63

Closed
bastianh opened this issue Jan 9, 2016 · 3 comments
Closed

error handling on websocket connect #63

bastianh opened this issue Jan 9, 2016 · 3 comments

Comments

@bastianh
Copy link
Contributor

bastianh commented Jan 9, 2016

I'm currently a bit unhappy with the error handling in the messages.

The websocket connect message for example... any error or exception happening in there will keep the connection open and the client will be able to continue sending messages.

It should be possible to drop the connection attempt by raising permission denied for example or it should fail with a error 500 on other exceptions.

Bastian

@andrewgodwin
Copy link
Member

Yes, that's a good point - a decorator would do the job, if you think that would work? Something like:

@websocket.close_on_error
def connect(message):
    raise ValueError()

I don't want to make the actual function itself special in any way. There's also the potential for something like a class-based-view approach.

@bastianh
Copy link
Contributor Author

I guess that would be a solution that would not require any changes.

I would prefer a solution that would directly work in the request where the websocket ist created (to fail that with forbidden for example) but I guess thats not easy to do.

@andrewgodwin
Copy link
Member

New ASGI stuff has fixed this, if the connect handler fails the websocket handshake is not even finished.

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

No branches or pull requests

2 participants