I am using flask-socketio to make a socket connection from my python web server to the javascript client. I am able to establish the connection but it breaks in a while(5 seconds or so) with the error
socket.io.min.js:2 WebSocket connection to 'ws://localhost:5000/socket.io/?EIO=3&transport=websocket&sid=8ed663e14c6f47328b64f2d29a30d1cd' failed: Received a broken close frame containing invalid UTF-8.
Server side code to send the message(calling this periodically, say every 5 seconds)
def send_message(result):
# it will forward the message to all clients.
print("sending message")
socketio.send("Send working", json=False)
Client side code to receive the message
socket.on('message', function (data) {
console.log('message form backend ' + data);
});
Somehow it breaks -> then nothing happens for a while -> then connect again automatically -> then breaks again.
Can someone please help? Thanks a lot!