I use this package and it work properly on test websites but in app I got this Error
WebSocketException: Connection to 'https://socket.excopro.com:0/socket.io/?EIO=3&transport=websocket#' was not upgraded to websocket
and this is my Code
SocketService() {
var socket = io(
'https://socket.excopro.com:443/', <String, dynamic>{
'transports': ['websocket'],
'autoConnect': true,
});
socket.on('connect', (_) {
print('connect');
socket.emit('msg', 'test');
});
socket.on("connecting", (data) => print('connecting'));
socket.on('connect_error', (data) {
print(data);
socket.emit('msg', 'test');
});
}
I have met the same issue.
For my case, I use Nginx as proxy. I solve the issue by added some proxy header to my Nginx configuration.
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
You can refer to this link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With