socket.io-client-dart icon indicating copy to clipboard operation
socket.io-client-dart copied to clipboard

Dart socket client cannot connect to node socket server

Open mulieli opened this issue 3 years ago • 12 comments

Always prompt timeout

mulieli avatar Jan 30 '21 08:01 mulieli

if you are using socketIO server version 3 please use socket io version 2.3 or below and if you are on android or ios latest version you need to make few setting to connect to unsecure connections(http) follow this link

jayaram9877 avatar Jan 31 '21 13:01 jayaram9877

@mulieli FYI: https://github.com/rikulo/socket.io-client-dart#usage-flutter

@jayaram9877 With socket.io server version 3, you can use socker.io-client-dart 2.0.0-beta version - https://pub.dev/packages/socket_io_client/versions/2.0.0-beta.2

jumperchen avatar Feb 01 '21 03:02 jumperchen

If you use socket.io version 3, go to your pubspec.yaml file and change the package version for socket_io_client: ^2.0.0-beta.2.

I made the error of installing it with pubspec plugin of VScode and I dont check the installed version.. Shame on me haha

It works butter great for me now! Thanks to this post and @jumperchen to make me realise that!

t1gu1 avatar Feb 14 '21 19:02 t1gu1

Have you solved the problem @mulieli ? I have timeout on my iOS and Android simulator in Flutter every time the NodeJS server is running on a network connected VM. When the server runs locally on my dev machine, it runs fine. CORS are configured and working in browser app. Anyone any ideas? Flutter 1.25.0-8.3.pre Dart SDK version: 2.12.0-133.7.beta SocketIO 2.0.0-beta.2 SocketIO (Server) 3.0.4

danielgottbehuet avatar Feb 15 '21 18:02 danielgottbehuet

I have solved my problem. The network traffic on localhost (local NodeJS server) was ok over http. But to other IPs (e.g. my VM on a Synology) must be on https!

danielgottbehuet avatar Feb 17 '21 17:02 danielgottbehuet

If you use socket.io version 3, go to your pubspec.yaml file and change the package version for socket_io_client: ^2.0.0-beta.2.

I made the error of installing it with pubspec plugin of VScode and I dont check the installed version.. Shame on me haha

It works butter great for me now! Thanks to this post and @jumperchen to make me realise that!

work for me, but don't forget to add setTransports(['websocket']) when connect

vantuan88291 avatar Feb 25 '21 08:02 vantuan88291

Can this be updated in the README and in Pub.dev. This is not that obvious since npm is installing the latest version which is > v3 - and my expectation (although incorrect) was that i was getting the latest version in pubspec.yaml ?

pradt avatar Mar 07 '21 16:03 pradt

@pradt done. :)

jumperchen avatar Mar 10 '21 08:03 jumperchen

@pradt done. :)

Awesome thanks @jumperchen !

pradt avatar Mar 10 '21 13:03 pradt

Im using socket_io_client: ^2.0.0-beta.2 (flutter) socket.io : 3.1.2 (server) But when I try to connect to the socket in flutter , nothing happens at all, it does not connect and it does not give an error.

IO.Socket socket = IO.io('http://inodari.satanapp.ir'); socket.connect(); socket.onConnect(() { print('connect'); socket.emit('msg', 'test'); }); socket.on('status', (data) => print(data)); socket.onDisconnect(() => print('disconnect'));

mahdinazmi avatar Nov 26 '21 19:11 mahdinazmi

@mahdinazmi try adding this <application android:usesCleartextTraffic="true"/> to your AndroidManifest.xml file.

jayaram9877 avatar Nov 27 '21 03:11 jayaram9877

@mahdinazmi try adding this to your ndroidManifest.xml file.

Excuse me, what should I add?

mahdinazmi avatar Nov 27 '21 06:11 mahdinazmi