Closed talalz94 closed 3 years ago
Fix: Updated Flask-SocketIO 4.3.2 to the latest version and used vue-socket.io-extended instead of vue-socket.io
Specify the transports method in options
can fix:
Vue.use(new VueSocketIO({
debug: true,
connection: 'http://localhost:8989',
vuex: {
store,
actionPrefix: 'SOCKET_',
mutationPrefix: 'SOCKET_'
},
options: { path: '/ws/socket.io', transports: ['websocket'] },
}))
I'm working on an application that uses Flask-SocketIO server with Vue.js on the client side. The issue is that when the app is deployed on NGINX server (version 1.21), it always uses polling and I keep getting following requests:
https://xyz.com/socket.io/?EIO=3&transport=polling&t=Nmo5P0n&sid=400eb01430964fc29b7b4cbf627b62aa
However when I deploy the application locally, the websocket are used perfectly fine as the below request suggests.
ws://localhost:10001/socket.io/?EIO=3&transport=websocket&sid=2858466e586040a58190577fa8a24546
Libraries used are following:
Following is my code base:
Client (Vue.js)
Server (Vue.js)
NGINX Config
I have tried adding the
transports: ['websocket']
parameter in the client (Vue.js) file but that results in the following error:WebSocket connection failed: Error during WebSocket handshake: Unexpected response code: 400
I'd prefer to be using actual Websockets, does anyone know why SocketIO is falling back on polling?