Socket connection breaking frequently with flask-socketio Socket connection breaking frequently with flask-socketio flask flask

Socket connection breaking frequently with flask-socketio


I fixed it.

socketio = SocketIO(app,ping_timeout=5)

ping_timeout – The time in seconds that the client waits for the server to respond before disconnecting.So it will be disconnected after 5 seconds if you do nothing.

The solution is that: Make your client side send message to server before timeout.

Cause my server usually sends data, so I make my client side like:

socket.on('message', function (data) {    console.log('message form backend ' + data);    socket.send('data receive!');});