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

No reconnect method in WsProvider. #405

Open
overetch opened this issue Jan 29, 2024 · 5 comments
Open

No reconnect method in WsProvider. #405

overetch opened this issue Jan 29, 2024 · 5 comments

Comments

@overetch
Copy link

Hello,

How to implement reconnect function with built-in Ws Provider?

As a workaround I created custom Ws Provider that extends Provider, and implement it by myself.

@leonardocustodio
Copy link
Owner

You can pretty much catch the exception and call the connect method again. But I guess what you want is to auto-reconnect, is that correct?

@leonardocustodio leonardocustodio self-assigned this Jan 29, 2024
@overetch
Copy link
Author

auto reconnect would be a nice feature.

But my main problem with no 'onError' and 'onDone' callbacks. After losing internet connection Websocket connection will be lost as well as all subscriptions and queries. And there's no TimeOutException in websocket by default.

For example:
Class provider.dart [line 184 - 186]

    }).listen((message) {
      queries.remove(message.id)!.complete(message);
    });

And [line 203 - 207]

    }).listen((message) {
      final StreamController? controller =
          get SubscriptionController(message.subscription);
      controller?.add(message);
    });

'jsonStream' only listening for responses and completely ignores any errors.

@leonardocustodio
Copy link
Owner

I see. @Lohann was responsible for this part but not sure if he has free time to look into it. I'm going to check with him and if he is not able to take a look add to my queue here.

@Lohann
Copy link
Collaborator

Lohann commented Jan 30, 2024

Good catch @overetch, will fix this week when I have some free time.

@leonardocustodio
Copy link
Owner

@Lohann were you able to look into this?

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

3 participants