wsproto icon indicating copy to clipboard operation
wsproto copied to clipboard

Attempt to close with local-only codes (e.g. 1006) results in normal close (1000)

Open samsamoa opened this issue 2 years ago • 0 comments

Currently, if you close a websocket with code 1006 (which is not allowed), the result is a 1000-code closure: https://github.com/python-hyper/wsproto/blob/main/src/wsproto/frame_protocol.py#L576-L577

I suspect this should instead be either a 1002 error or an exception, but I'm not certain.

This resulted in a latent bug in hypercorn (an ASGI web server that uses wsproto) where websockets were closed with code 1000 on internal server errors: https://github.com/pgjones/hypercorn/pull/112

samsamoa avatar Mar 18 '23 15:03 samsamoa