WebSocketException: Connection to 'https://mydomain.com:0/socket.io/?EIO=4&transport=web_socket#' was not upgraded to websocket
I am trying to connect socket_io_client: ^2.0.0-beta.4-nullsafety.0 to a Nodejs server socket.io - 3.0.3. I am getting error WebSocketException: Connection to 'https://mydomain.com:0/socket.io/?EIO=4&transport=web_socket#' was not upgraded to websocket.
From the read me I suppose version 2.0.0-beta.4-nullsafety.0 is compatible with ```socket.io 3.0.3``
same problem here on flutter master channel.
Same for me !
@abinmittu Are you using nginx in your server?
Same for me !
Yes!!
On Wed, 9 Jun 2021 at 22:54 kameshkarthi @.***> wrote:
@abinmittu https://github.com/abinmittu Are you using nginx in your server?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rikulo/socket.io-client-dart/issues/200#issuecomment-858219334, or unsubscribe https://github.com/notifications/unsubscribe-auth/APUDJKPTAZHUIYANLM3YV2TTSALOBANCNFSM4526BTFA .
@evaleiraswembii add this in your nginx config file
location /socket.io/ { proxy_pass http://servers; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
change servers to your domain.
Is the :0 behind the normal expected behavior?
I had the same problem with socket_io_client: ^2.0.0-beta.4-nullsafety.0, nginx and flask-socketio==5.1.0. But the fix provided by @kameshkarthi works fine for me. Thank you so much!
Is the :0 behind the normal expected behavior?
I have the same question , why the port is becoming zero ?
@Djihanegh I think the issue is with the file socket_io_client.dart:49. If no port is passed then due to null safety it takes default int value 0.
Solution:
For those who are looking solution for it, pass a port number while connecting. If no custom port by server, for ws pass 80 for wss pass 443. Example:
import 'package:socket_io_client/socket_io_client.dart' as IO;
IO.Socket socket = IO.io(
'wss://socket.example.com:443',
IO.OptionBuilder()
.setTransports(['websocket'])
.build());
I have the same problem and my problem started after deploying my Node.js app to Azure. Maybe kameshkarthi's solution works but I don't know if I can change the configuration in Azure.
Dam, we're stuck at the moment cause we can't specify a port on the domain. Sucky bug! Has someone made a PR yet?
I have the same question , why the port is becoming zero ?
It's a quick fix on the library if you download it. (If someone can make a PR)
Change
var id = '${parsed.scheme}://${parsed.host}:${parsed.port}';
To
String port = parsed.port != null ? ":" + parsed.port : "";
var id = '${parsed.scheme}://${parsed.host}${port}';
same error ...
brary if you download it. (If someone can make a PR)
i try this, but not working