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
'Received a broken close frame containing invalid UTF-8' upon receiving an emit on client-side #755
Comments
Can you create a simple self-contained example that shows this error? |
I resolved the issue by switching to eventlet from the standard flask dev server, it was an issue with my code, thanks for the quick response anyways! |
I am trying to do the same thing (I invoke emit with a separate thread but nothing happens until many seconds later) but I get this error and am not sure how to fix it. I am using eventlet with gunicorn. Any suggestions? |
@mbwolff do you have an example I can use to reproduce the problem? |
Here's an example based on the code I'm developing. To launch the server I use
I simulated the delay from the threaded function with sleep(5). After about 30 seconds after the thread completes its task I get the following error:
Thanks for taking a look at this! |
@mbwolff Not sure what I'm looking for. I go to |
@miguelgrinberg The sonnet page should load after the form is submitted and then update via socketio and Javascript with |
I fixed a few things in I'm still getting the same errors. |
You are not running the app in the right way, you need to use |
Does anyone have a solution for this? I'm having the same problem. |
I also have the same problem. |
@danielkrich @vonsky104 if you can provide a complete example application that reproduces the issue I'm happy to investigate. |
I was receiving the same issue, and what I did to fix it was actually in the JS. emit('start', data) # The data could be anything and the code on the client-side (JS) looked like this (socket is the object returned after socket.on('start', function start(){/* Some code */}); What I did to fix this was to add the variable data into the parameters for the socket.on('start', function start(data){/* Some code */}); I hope this helps! |
I had the same issue with Checking the error messages I ended up on the More specifically I got an exception: AttributeError: module 'wsaccel.utf8validator' has no attribute `Utf8Validator` After uninstalling and installing again (even without installing it seems to work) the package I hope it helps someone! |
I met this issue when attempting to broadcast messages in a background thread, and I was able to fix it by setting up the monkey patching: import eventlet
eventlet.monkey_patch() I also had to set |
@miguelgrinberg, I'm also facing the same issue. I tried monkey_patch, setting async_mode, decreasing ping_timeout. But nothing seems to work. Any suggestions? Also, the behavior is not consistent. The values are published on the website which confirms that it is not a connection issue. I'm guessing it has something to do with my timeout. |
@jalapatip As I told every other person who commented in this thread. If you can provide a runnable example that demonstrates the issue I can investigate. You are not providing anything, so I really have nothing to suggest. |
@miguelgrinberg, I'm attaching a drive link containing an executable sample of my code. I also attached the logs from the console and web interface. https://drive.google.com/drive/folders/1IF_ZVQ6ZCEKMQtX3WJnX26x7jbplocri?usp=sharing Thanks for helping me debug! |
@jalapatip your application does not produce any errors for me. |
That's strange! I'm getting the following error in the browser. I also tried switching between chrome and firefox.
How are you running the application? |
python app.py |
So, I was able to host the service using gunicorn and it's publishing:
But not when I do a simple:
Any idea, what could be the issue? |
@jalapatip I don't understand what you mean by "it's publishing". In any case, any times there are errors or issues you should check out the server log for clues. |
@miguelgrinberg, I have checked the server logs and see that it is emitting messages. The idea is to display these messages on a UI. On the console, I see the following error: I thought it had something to do with the structure of the message. But this is not a consistent issue. The thread emitting messages runs in a loop and the messages do get printed on the UI sometimes. Other than that, I couldn't find any other errors or useful insights in the debug, error, and info logs (except for the above logs from console). I've also attached the same in the drive link earlier. Also, this is only happening when I run |
@jalapatip You have issues when you run a development build. You are using eventlet, and you also have the reloader enabled. Any of these things can be the problem, eventlet and gevent are known to be problematic when used with concurrent code that is not specifically designed with greenlets in mind. Things you can try:
I'm not sure what other options you have beyond trying different combinations as the above examples. |
I'm sending a simple message by doing
socket.emit('blabla', {'wow': 20000})
I invoke the function which invokes that and nothing happens until ~30 seconds later my client connection snaps and it prints out Received a broken close frame containing invalid UTF-8 in Chrome console.
Now, the function from which I invoke the emit is run in a separate thread, but uses the same SocketIO object for communication, seems that that messes things up, any clues?
The text was updated successfully, but these errors were encountered: