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

[Feature] Reason for websocket.close #991

Closed
Chaostheorie opened this issue Jul 4, 2020 · 8 comments · Fixed by #1417
Closed

[Feature] Reason for websocket.close #991

Chaostheorie opened this issue Jul 4, 2020 · 8 comments · Fixed by #1417
Labels
websocket WebSocket-related

Comments

@Chaostheorie
Copy link

I've recently started actively developing with websockets in starlette. When closing a websocket you can provide a code e.g. 1000, 1008 … to tell the client the basic reason. But the websocket protocol allows the developer to also give UTF-8-encoded data as a complementary description/ reason. This would be useful in multiple cases such as mentioning the specific violitioan for code 1008 (POLICY VIOLIATION). Websockets supports this too and their implementation could maybe help.

Specification: https://tools.ietf.org/

@Chaostheorie Chaostheorie changed the title [Feature Request] Reason for websocket.close [Feature] Reason for websocket.close Jul 4, 2020
@Chaostheorie
Copy link
Author

Created basic implementation in #992

@abersheeran
Copy link
Member

https://asgi.readthedocs.io/en/latest/specs/www.html#close-send-event

This is not in the ASGI protocol, so it cannot be achieved.

@tomchristie
Copy link
Member

Thanks @abersheeran yup seems correct to me too.

"code" is part of the ASGI spec, but "reason" isn't. If the ASGI spec evolves there at some point, then we could consider it.

@Armster15
Copy link

"reason" has been added to the ASGI spec. Will this library add it now as well?

@abersheeran abersheeran reopened this Nov 15, 2021
@abersheeran abersheeran added the websocket WebSocket-related label Nov 15, 2021
@Chaostheorie
Copy link
Author

The code from #992 should still be able to be used … Well, up for grabs

@Kludex
Copy link
Sponsor Member

Kludex commented Nov 22, 2021

Should we wait it to be release on the ASGI website? In any case, PR is more than welcome. Thanks @Chaostheorie :)

@Armster15
Copy link

The reason attribute is also on the ASGI documentation https://asgi.readthedocs.io/en/latest/specs/www.html#close-send-event

@Kludex
Copy link
Sponsor Member

Kludex commented Nov 22, 2021

When I wrote my comment, it was not :)

They just fixed the docs (I asked them the reason 😅).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
websocket WebSocket-related
Projects
None yet
5 participants