miguelgrinberg / flask-sock

Modern WebSocket support for Flask.
MIT License
272 stars 24 forks source link

Is Flask-Sock binary safe? (are there any escape characters?) #61

Closed tschesnok closed 1 year ago

tschesnok commented 1 year ago

I'm having issues with bytes that are larger than 127. Anything using the signed or 8 bit is creating an error the server is returning:

'utf-8' codec can't decode byte 0x8c in position 4: invalid start byte

Probably not your code.. but I just want to get that checked off. :)

miguelgrinberg commented 1 year ago

@tschesnok share a complete stack trace please. Without that I have no way to know what this is about.

tschesnok commented 1 year ago

I'm not sure how to do that. There are no server side error messages in the console. My server side code simply prints "packet received" on incoming packets. When I send packets from the client (in C++) if one of the bytes is larger than 127 then the server sends back a packet containing the message above with the hex indicating the position of the byte in the buffer that is larger than 127. I also don't get a "packet received" print in that instance. This may very well be something in our code. I just wanted to hear that bytes above 127 should be fine..

miguelgrinberg commented 1 year ago

I think it must be your server that is sending error messages as websocket packets, Flask-Sock does not do that, at least not intentionally.

The WebSocket protocol supports both text and binary messages. Which type is your C++ application sending? If it sends text messages, then the text should be encoded in UTF-8. If it sends binary, it can send anything it wants.

tschesnok commented 1 year ago

Thank you. I think that may be the clue.. we may be sending binary data while it is expecting UTF-8.