miguelgrinberg / simple-websocket

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

Wrong content when send/receive large message(about 4MB) #34

Open xfeep opened 9 months ago

xfeep commented 9 months ago

env: Linux (Ubuntu 22.04) + python 3.10.10 + simple-websocket 1.0.0

In this case both client and server are used together with flask + gevent + monkey.patch_all(). When the client send a large message the server will receive wrong conent which seems bad tail. e.g.

Client side:

sent:  msg size:3834249 
msg[0:10]:  b'\x80\x04\x95\xbf\x05\x00\x00\x00\x00\x00' 
msg[-10:]:  b't\x94bububub.'

Server side:

received:  msg size: 3834249
msg[0:10]: : b'\x80\x04\x95\xbf\x05\x00\x00\x00\x00\x00'
msg[-10:]: b'\xd4\xa5{i\xe2\xb0\xa6\xbc\x0b='

We can see the received tail is wrong. So either client or server gets wrong.

miguelgrinberg commented 9 months ago

Please create small server and client apps that I can use to reproduce this issue. The information you provided is insufficient for me to test or diagnose the issue. Thanks.

xfeep commented 9 months ago

@miguelgrinberg Hi, Grinberg! Thanks for your quick reply. If I'm free I'll try to create a minimal codebase to reproduce it. But now I've reverted back to using HTTP-PUT instead of websocket.