Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not act to connecting or not connection #60

Open
tazik561 opened this issue Feb 19, 2020 · 5 comments
Open

Not act to connecting or not connection #60

tazik561 opened this issue Feb 19, 2020 · 5 comments

Comments

@tazik561
Copy link

tazik561 commented Feb 19, 2020

I am using this code to connect to socket io server :

  @override
  void initState() {
    super.initState();
    IO.Socket socket = IO.io('https://socket.***.**', <String, dynamic>{
      'transports': ['websocket'],
      'autoConnect': true,
    });
//    socket.connect();

    socket.on('connect', (_) {
      print('connect');
      socket.emit('msg', 'test');
    });

    socket.on('connecting', (data) => print("connecting"));
    socket.on('reconnect', (data) => print("reconnect"));
    socket.on('reconnect_attempt', (data) => print("reconnect_attempt"));
    socket.on('reconnect_failed', (data) => print("reconnect_failed"));
    socket.on('reconnect_error', (data) => print("reconnect_error"));
    socket.on('reconnecting', (data) => print("reconnecting"));
    socket.on('event', (data) => print(data));
    socket.on('ping', (data) => print("pinging"));
    socket.on('error', (error) {
      print('error');
      print(error);
    });
    socket.on('receive_message', (data) => print(data));
    socket.on('disconnect', (_) => print('disconnect'));
    socket.on('fromServer', (_) => print(_));

    socket.open();
  }

But after running i got this messages:

I/flutter ( 9336): reconnecting
I/flutter ( 9336): reconnect_error
I/flutter ( 9336): reconnect_attempt
I/flutter ( 9336): reconnecting

What is a problem ? and how can i find out that what is a problem?

@jumperchen
Copy link
Member

This example works for me - #36 (comment)

@tazik561
Copy link
Author

socker server that i use , used https and implemented with c# . those code have not difference to my code and i still can not able to connect to https server.

@jumperchen
Copy link
Member

@tazik561 is that server (c#) a Socket.io NodeJS-compliant server?
If so, it should work.

@tazik561
Copy link
Author

tazik561 commented Feb 20, 2020

I do not know and i will ask a developer who write server .But this is other question i asked in stackoverflow: https://stackoverflow.com/questions/60302062/flutter-engineioexception-websocket-error .
I used adhara and with this library i got error too. in this question i mentioned that with socket.io tester chrome extention i can connect to server but flutter libraries can not connect to server!!
What is your idea? What is my problem?

@jumperchen
Copy link
Member

@tazik561 can you try to run the pure dart code first, if it can connect to your server, then the problem may be only inside the flutter env. issue, if not, then I think the problem may be the websocket protocol issue, because the dart:io can only support websocket protocol and it's different from browser dart:html which uses poll protocol first and then switches to websocket if possible.
So according to your post on stackoverflow, I could guess the chrome plugin using poll protocol to connect to your server at the first time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants