Skip to content
New issue

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

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

Already on GitHub? # to your account

How to differentiate connecting and connected states? #1610

Closed
nailgilaziev opened this issue Jun 5, 2018 · 3 comments
Closed

How to differentiate connecting and connected states? #1610

nailgilaziev opened this issue Jun 5, 2018 · 3 comments

Comments

@nailgilaziev
Copy link

First snapshot that StreamBuilder receives is ConnectionState.waiting
This happens when connecting started and in progress.

after connection is established we do not receive any new snapshots. This is undetermined state.
used this code https://flutter.io/cookbook/networking/web-sockets/
print lines added to track snapshots

new StreamBuilder(
  stream: widget.channel.stream,
  builder: (context, snapshot) {
    print("connection state ${snapshot.connectionState}");
    print("data ${snapshot.data}");
    print("error ${snapshot.error}");
    return new Padding(
      padding: const EdgeInsets.symmetric(vertical: 24.0),
      child: new Text(snapshot.hasData ? '${snapshot.data}' : ''),
    );
  },

in logs you see only

I/flutter ( 7150): connection state ConnectionState.waiting
I/flutter ( 7150): data null
I/flutter ( 7150): error null

If connection successful - last snapshot is ConnectionState.waiting
If connection not successful and will die in future (ConnectionTimeout around 2 min) - now you see ConnectionState.waiting and can't decide what to do.

snapshot will be active only when server sends some data to client.

@nailgilaziev
Copy link
Author

detailed info about connectionTimeOut in https://github.com/dart-lang/web_socket_channel/issues/22

@nex3
Copy link
Member

nex3 commented Jun 5, 2018

The StreamBuilder and ConnectionState classes are both from Flutter; I'm moving this issue to their repo.

@nex3
Copy link
Member

nex3 commented Jun 5, 2018

This issue was moved to flutter/flutter#18204

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

No branches or pull requests

3 participants