'Flask-SocketIo always using Polling
I have made an web app with flask and implemented socket-io in it using Flask-SocketIO
but it is continuously using Polling method instead of Web Sockets.
My JS
file:
$(document).ready(function(){
socket = io.connect(document.location.protocol + '//' + document.domain, {rememberTransport: false});
socket.on('connect', function() {
console.log('Websocket connected!');
});
socket.on('status', function(data) {
console.log("HIIIIII");
});
});
And my app.py
file:
from flask import Flask
from flask_socketio import SocketIO, emit
app = Flask(__name__)
# My all other functions
@socketio.on('connect')
def connect_handler():
print("f")
@socketio.on('status')
def status(message):
emit('status', {'msg': session.get('name') + ' has entered the room.'})
if __name__ == '__main__':
app.debug = True
socketio.init_app(app)
socketio.run(app)
And my Chrome Console is generating the following polling error:
GET https://example.com/socket.io/?EIO=4&transport=polling&t=O2ylx6M 404
It is hosted on vercel.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|