-
-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling of binary data fails sometimes #37
Comments
If I change server.py l. 437 to
I wonder why this only happens since I upgrade Python to 3.5 |
Could you add a print statement for the variable |
Sure! The content of ep is a byte-string of a pdf file. It looks like this:
and so on (becomes unreadable from there on) the end looks like this if this is of any interest:
|
Are you doing anything with PDF files? |
Yes, the client sends them via websocket in binary format to the server. |
Are you sending the PDF as a standalone payload, or is it part of a larger data structure, maybe something like Actually, can you show me the portion of the client code that emits these PDFs? |
This is the signature of the function that handles the client message.
If I print the content of the first parameter (json_data) it says: So to answer your question: as a part of a larger data structure. And then again it only happens when I have multiple threads running that try to accept the client messages. If I only send one request at a time (and a few more are also ok) it works. However for 10 and more I get these errors. |
Yeah, sounds like when several of these PDF attachments are flying the server sometimes loses one and treats it as a standalone message. This is useful, I think I have enough to reproduce the problem. Thanks. |
Okay cool! If you need further information like a concrete payload that causes the problem let me know. Thanks in advance. Oh and do you have any clue why this only happens since I updated Python to 3.5? |
Can you explain this statement in detail? Are you talking about server-side threads or client-side? |
Yes, it's about server-side threads. I handle every request in a separate thread as I have resource hungry calculations running (OCR) that should not block further incoming requests. |
Not sure I understand how your use of threads affects the internals of the socket.io server. You are instantiating only one server, correct? Can you show me the code that spawns your threads? |
If it helps you to reproduce the problem I could even send you a script that reproduces the problem (that will take some days though because I am currently not at home) |
Okay, this should be fine, in fact the functions attached to "on" decorators are executed in independent threads anyway. If you can send me an example that reproduces the problem that would be most helpful. Thanks! |
It was a hard task but I managed to boil everything down to a few lines of code (in js and in python as well). http://s000.tinyupload.com/index.php?file_id=69252726138999738284 here is a zip containing the js file, the py file and two client-side dependencies (jquery and socketio). If you have any problems launching it or anything, let me know. I used tinyupload the first time, I hope the file stays there long enough. In order to reproduce it start main.py with python3. On the client side just click on the input element and choose 15-20 files at once (I tested it with pdf. I don't know if other filetypes work as well. Guess so) |
Thanks, got the file. How do I trigger the error? Select a file and keep doing it until it fails? |
On my machine (MacBook Pro 2013) I had to just choose many (about 15) files (each at least 1mb big I think) in the file dialog. That triggers socketio to send it to the server and immediately led to the errors explained in my first post. |
I chose the files all at once in the dialog |
Can I ask you to retest with the master branch? I think the fix that I just made will address the problem with the binary attachments. Thanks a lot, the example you provided was immensely helpful. |
Awesome! It works. Thanks for the uncomplicated way of communicating and the tremendous speed! 👍 |
After updating flask-socketio from 1.2 to 2.6 I have a strange error that comes up occasionally when there are more than a few threads that handle a binary message from a socket.io client. I get the following error:
I just noticed is has nothing to do with the upgrade of flask-socketio. I upgraded python from 3.4 to 3.5 as well and this is probably the cause. Downgrading flask-socketio did not make it work. So it probably has to do with python-socketio for python 3.5
The text was updated successfully, but these errors were encountered: