简体   繁体   中英

Flask Socket.IO seems to revert to polling

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?

在此处输入图片说明

Thanks for the help

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM