Hi I have following flask socketio code
from flask import Flask, request, jsonify
from flask_socketio import SocketIO
app = Flask(__name__)
app.secret_key = 'secret'
async_mode=None
socketio = SocketIO(app,async_mode=async_mode,cors_allowed_origins="*")
app.debug = True
@app.route('/', methods=['GET'])
def index():
return 'Welcome!'
@socketio.on('connect')
def test_connect():
print('Client Connected')
@socketio.on('disconnect')
def test_disconnect():
print('Client disconnected')
if __name__ == '__main__':
socketio.run(app,debug=True,host='0.0.0.0',port=3000)
And I am connecting to this flask-socket io server from flutter using the following code
//using socket-io-client
IO.Socket socket = IO.io('http://192.16x.x.x:3000/', <String, dynamic>{
'transports': ['websocket']
});
socket.onConnect((_) {
print('connect');
});
socket.onDisconnect((_) => print('disconnect'));
But whenever I try to connect, I am getting these loads of unwanted messages on server side.
"GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 195 0.000995
(9784) accepted ('192.168.100.1', 58740)
192.168.100.1 - - [24/May/2021 22:58:15] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 195 0.000997
(9784) accepted ('192.16x.x.x', 58744)
192.168.100.1 - - [24/May/2021 22:58:20] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 195 0.000995
(9784) accepted ('192.16x.x.x', 58747)
192.168.100.1 - - [24/May/2021 22:58:25] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 195 0.000996
(9784) accepted ('192.16x.x.x', 58750)
192.168.100.1 - - [24/May/2021 22:58:30] "GET /socket.io/?EIO=3&transport=websocket HTTP/1.1" 400 195 0.000996
I saw this post Here and used that cors allow parameter in socketio code but still I cannot get rid of these messages. Also the server nor the client side prints 'connected' or nething one connect, so i am assuming the socket connection didn't happen. So how do I fix this? anyone?