4

i am trying to implement socket.io with my flutter app, currently flutter is supporting WebSocket but i have found a way for socket.io in package "dart.io" but i am unable to understand how to emit a message on a specific event. Any suggestions would be helpful :)

6
  • Perhaps pub.dartlang.org/packages/flutter_socket_io Commented Oct 29, 2018 at 7:23
  • Thanks for this GünterZöchbauer :) i think you are right, will test it soon. Commented Oct 29, 2018 at 9:29
  • i have tested this plugin but it is unable to connect, My native android side is working find. createSocketIO() has 4 parameters, i have input the domain, have no namespace so i tried empty string and null also but no success in sending the message. Logcat shows the isConnected:false. Need help on this one. Commented Oct 31, 2018 at 18:19
  • I think you can read in the documetation about websockets first, flutter socket.io and flutter socket.io client too Commented Nov 30, 2018 at 20:56
  • Hello @rize thanks for the answer, i tried flutter socket.io client. Just by calling the IO.Socket socket = IO.io(SOCKET_URL); socket.connect(); then i get an error of Commented Dec 4, 2018 at 23:14

3 Answers 3

3

I have ported socket.io in dart code since 2017, and it can work with flutter as well in the same codebase - socket.io-client-dart and socket.io-dart.

Sign up to request clarification or add additional context in comments.

Comments

1

Using this flutter_socket_io package, I managed to connect to my local Socket IO server.

SocketIO socket = SocketIOManager().createSocketIO("http://localhost:3000", "/");
socket.init();
socket.connect();

Maybe you could share your implementation on both client and server side to debug further.

Comments

0

I think you looking for this flutter_socket_io

4 Comments

check my last comment to Günter Zöchbauer. "i have tested this plugin but it is unable to connect, My native android side is working fine. createSocketIO() has 4 parameters, i have input the domain, have no namespace so i tried empty string and null but no success in sending the message. Logcat shows the isConnected:false. Need help on this one"
use "/" in namespace parameter as default namespace in socket io
namespace as you said but still the socket status is interchanging from "reconnecting" to "disconnect" socketIO = SocketIOManager().createSocketIO(SOCKET_URL, "/", socketStatusCallback: _socketStatus); socketIO.init(); socketIO.connect();
i am pretty sure thats not the issue, internet permission is also in the android manifest.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.