Flask-SocketIO: 'Received a broken close frame containing invalid UTF-8' upon receiving an emit on client-side

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?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25 (10 by maintainers)

Most upvoted comments

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 "gevent": true in my VSCode debugging configuration to solve another problem that came with the monkey patching.