socket.io-client-dart
socket.io-client-dart copied to clipboard
Dart socket client cannot connect to node socket server
Always prompt timeout
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
@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
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!
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
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!
If you use socket.io version 3, go to your
pubspec.yaml
file and change the package version forsocket_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
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 done. :)
@pradt done. :)
Awesome thanks @jumperchen !
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 try adding this <application android:usesCleartextTraffic="true"/>
to your AndroidManifest.xml file.
@mahdinazmi try adding this to your ndroidManifest.xml file.
Excuse me, what should I add?