miguelgrinberg / simple-websocket

Simple WebSocket server and client for Python.
MIT License
78 stars 17 forks source link

permessage-deflate compression support #11

Closed wilson0028 closed 2 years ago

wilson0028 commented 2 years ago

Is permessage-deflate compression supported on flask-sock? I know this is implemented with flask-socketio if you use eventlet but I can't seem to make compression work with flask-sock.

This is a great project and thank you for your work!

miguelgrinberg commented 2 years ago

Flask-Sock does not have its own websocket implementation, it relies on a 3rd party package. The support and negotiation of websocket extensions such as the one for message compression happens during the connection handshake and is not part of Flask-Sock duties.

Which websocket package are you using? I assume simple-websocket? I think that should work too, but I don't recall ever testing compression with this package.

wilson0028 commented 2 years ago

I am using simple-websocket on the browser side and of course Flask-Sock on the server side. In the image below, you can see that the browser does ask for permessage-deflate but the response from the server doesn't include it.

Thank you for the information. I guess at this point I'll just need to use Flask-SocketIO to get compression.

web

miguelgrinberg commented 2 years ago

If you like the eventlet websocket why don't you use that instead of simple-websocket? I'm going to look into why simple-websocket does not accept compression, but Flask-Sock also works with eventlet and gevent websocket servers (documentation).

miguelgrinberg commented 2 years ago

Update: I believe I have found the issue with the compression extension. Will be fixed shortly.

wilson0028 commented 2 years ago

I was going to add that I did try Flask-Sock with eventlet but was still unable to get compression to work. Hopefully that is related the the issue you found.

miguelgrinberg commented 2 years ago

@wilson0028 if you install the main branch of simple-websocket you should be able to use compression, with all web servers.