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

Flutter iOS: Connection was disconnected after changing network state between wifi <> cellular (grpc-dart - version 3.0.2) #564

Closed
ThanhDat-Vo opened this issue Jun 26, 2022 · 1 comment

Comments

@ThanhDat-Vo
Copy link

ThanhDat-Vo commented Jun 26, 2022

Stream stops receiving messages after changing network state

grpc-dart version: 3.0.2

Repro steps

  1. start the unary grpc request from Flutter iOS app
  2. switching between wifi <> cellular
  3. the request was hang forever

Expected result: connection should be kept after changing network state

Actual result: connection was disconnect. After long period of time, an UNAVAILABLE grpc error code returned.

Related problems:

Please help!

Thanks

@ThanhDat-Vo ThanhDat-Vo changed the title Flutter iOS: grpc-dart version: 3.0.2Connection was disconnected after changing network state (grpc-dart - version 3.0.2) Flutter iOS: Connection was disconnected after changing network state (grpc-dart - version 3.0.2) Jun 26, 2022
@ThanhDat-Vo ThanhDat-Vo changed the title Flutter iOS: Connection was disconnected after changing network state (grpc-dart - version 3.0.2) Flutter iOS: Connection was disconnected after changing network state from wifi <> cellular (grpc-dart - version 3.0.2) Jun 26, 2022
@ThanhDat-Vo ThanhDat-Vo changed the title Flutter iOS: Connection was disconnected after changing network state from wifi <> cellular (grpc-dart - version 3.0.2) Flutter iOS: Connection was disconnected after changing network state between wifi <> cellular (grpc-dart - version 3.0.2) Jun 26, 2022
@mraleph
Copy link
Member

mraleph commented Jun 27, 2022

By default grpc-dart uses package:http2 which uses dart:io underneath which uses BSD sockets, so the behaviour you are seeing is expected.

Right now the best solution you can come up with is to implement some code on the side to monitor network state changes and manually drop old connection and reconnect when network state changes.

As noted in the linked doc a possible solution to this problem would be to connect over CFStream - but currently we don't have a networking stack implementation that could do it. /cc @brianquinlan

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

No branches or pull requests

2 participants