Flask Socket.IO seems to revert to polling

705 views Asked by At

So i'm using flask_socketio and using the example from here and when i visit the webpage my chrome dev console shows this. Are those polling requests just keeping the socket alive or is it reverting to polling?

enter image description here

Thanks for the help

1

There are 1 answers

0
Miguel Grinberg On

If you look at the last column in your screenshot, which shows a chart with the start time and duration of each request, you'll notice that the top request, the WebSocket request, is the one that started last, and it is ongoing (note it shows as pending).

The way Chrome sorts the requests is odd, it makes it look like Websocket was the first request, but that is not a correct interpretation.

There are a couple of things you can do to confirm that WebSocket is working correctly. First, you can click on that top line that shows the WebSocket request, and that will open a detailed view that will show the WebSocket frames that are being sent between the client and the server. You should see new stuff appearing there constantly.

The second thing you can do is to look at your server logs, to ensure there are no HTTP requests coming from the client. Long polling will show constant GET and POST requests being sent, if your logs are quiet, then the communication is going over WebSocket.