socket.io-client-dart
socket.io-client-dart copied to clipboard
Connection to 'url' was not upgraded to websocket
I am rewriting the existing kotlin app in flutter to support cross-platform. Socket url is working great in kotlin, but it throws an error while using it in flutter. Connection Error - "Connection to 'url' was not upgraded to websocket".
I am using socket_io_client: ^1.0.1.
FYI: https://github.com/rikulo/socket.io-client-dart#usage-flutter
Hi @jumperchen , I have already tried this, still getting same result.
here is my code snippet,
final String token = UserManager.sharedInstance.getAuthToken();
mSocket = IO.io(
UtilsGeneral.getApiBaseUrl(),
IO.OptionBuilder()
.setQuery({"token": token})
.setTransports(['websocket'])
.setExtraHeaders({'token':token, 'Connection': 'upgrade', 'Upgrade': 'websocket'})
.enableReconnection()
.setReconnectionDelay(1)
.enableForceNew()
.build());
Hi,
Is this issue resolved?
Am getting the same issue
WebSocketException: Connection to '
IO.Socket socket = IO.io('< mysocketurl >', OptionBuilder()
.setTransports(['websocket'])
.setExtraHeaders({'userId': '12345678'})
.build());
socket.onConnect((_) {
print('SOCKET CONNECTED');
socket.emit('msg', 'test');
});
socket.on('event', (data) => print(data));
socket.onDisconnect((_) => print('disconnect'));
socket.on('fromServer', (_) => print(_));
socket.on("connect_error", (data) => print("error " + data.toString()));
also getting the same issue, is there a known fix or work around?
I have the same issue with 2.0.0-beta.4-nullsafety.0. websocket#' was not upgraded to websocket My socket.io. version is "socket.io": "4.4.1"
_socket = io(
WebSocketConfiguration.webSocketUrl,
OptionBuilder()
.setTransports(['websocket']) // for Flutter or Dart VM
.disableAutoConnect()
.setTimeout(10000)
.setExtraHeaders({'Connection': 'Upgrade','Upgrade':'websocket'}) // optional
.build());
_socket.connect();
is there a known fix or work around?
I encounter same issue recently, it is connection error problem as version on client side and server same doesn’t match, try specifying version using https://github.com/rikulo/socket.io-client-dart.
Are there any updates on this?
I am having the same issue, It works for local but not connecting to the server, I have a server on AWS elasticbeanstalk.
Working code for local: but whenever I changed it to my test server it will not work. Please if anyone has resolved please advise.
void connectManually() {
Socket socket = io(
'http://10.0.2.2:5000',
OptionBuilder()
.setPath('/rt')
.setTransports(['websocket']) // for Flutter or Dart VM
.disableAutoConnect() // disable auto-connection
.setExtraHeaders({
'Connection': 'Upgrade',
'Origin': 'http://server.com'
}) // optional
.setQuery({'token': "babaji"})
.build());
socket.on('connect_error', (c) {
log(c.toString());
});
socket.connect();
socket.onConnect((_) {
print('connected to websocket');
});
}
FYI I am using: socket_io_client: ^2.0.0-beta.4-nullsafety.0
Same issue here. Any update on this?
Same here guys, Any updates?
i have same error any solution ?
Hello, We had integrated socket io in our flutter app with odoo backend so we had version mismatch issue, you can check the socket io version you are implementing on app side and socket io version implemented on backend side you will have to find an compatible version for both side, these helped us, hope it help you too