miguelgrinberg / flask-sock

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

server receiving broken data #6

Closed lancezhaozai closed 3 years ago

lancezhaozai commented 3 years ago

i used the flask-sock to receive a long message from client, its about a string with 2568 characters, it works sometime, the message received successfully, sometimes it broken with no error, i checked all the sending and receiving, i am sure that the message received was broken, do I have to increase the buffer size? or increase the data receiving size? or what should I do?

its easy to simulate the problem, its put in a super large size of string and keep sending and receiving, the error will will not raise but you will found out the string received was shorten

miguelgrinberg commented 3 years ago

I'm unable to reproduce this. I'm sending 2568 characters at a rate of 10 times/sec to the example server in this repo and every package is received with the correct length, and the reflected package also arrives at the client with the correct length.

Do you want to provide a complete example that I can use to reproduce the problem that you are seeing?

lancezhaozai commented 3 years ago

I will send you my payload tomorrow, today im off

On Sat, 22 May 2021 at 10:36 PM, Miguel Grinberg @.***> wrote:

I'm unable to reproduce this. I'm sending 2568 characters at a rate of 10 times/sec to the example server in this repo and every package is received with the correct length, and the reflected package also arrives at the client with the correct length.

Do you want to provide a complete example that I can use to reproduce the problem that you are seeing?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/miguelgrinberg/flask-sock/issues/6#issuecomment-846416948, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7FEUMHQX5T5IDJA44N7N3TO66OPANCNFSM45EDP4BA .

louking commented 1 year ago

FWIW, I'm seeing (short) messages dropped at the flask-sock server. See https://github.com/louking/tm-csv-connector/issues/15. I'm not sure if this is a different problem. If so I can create a separate issue.

I'm running a flask-sock application on python 3.10, using gunicorn, behind nginx. It appears the nginx server receives all the websockets messages but the gunicorn / flask server misses some. I tried increasing the number of gunicorn threads and workers, but that didn't help.

The source for all this is at https://github.com/louking/tm-csv-connector/tree/e114036e6c024eaae4ad1d26f68788655b45b11b

The docker build requires a bunch of javascript files external to the repo. The files are expected to be in static/js as indicated by https://github.com/louking/tm-csv-connector/blob/e114036e6c024eaae4ad1d26f68788655b45b11b/app/src/tm_csv_connector/assets.py

The docker app (websocket server) is started by docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build -d. The external (windows) app (websocket client) is started by python -m tm-reader-client.app

Note the tm-reader-client app is expecting an external device for input. This would have to be modified to just generate test messages.

Also some config files are required for the docker app to work. I can discuss offline somehow if you're interested in pursuing.

Similar to @lancezhaozai, due to time constraints I'm going to investigate flask-socketio, but since I came here I thought I'd give you a full implementation which is dropping messages.