polkadart icon indicating copy to clipboard operation
polkadart copied to clipboard

No reconnect method in WsProvider.

Open overetch opened this issue 1 year ago • 5 comments
trafficstars

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.

overetch avatar Jan 29 '24 06:01 overetch

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 avatar Jan 29 '24 15:01 leonardocustodio

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.

overetch avatar Jan 29 '24 17:01 overetch

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.

leonardocustodio avatar Jan 29 '24 17:01 leonardocustodio

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

Lohann avatar Jan 30 '24 14:01 Lohann

@Lohann were you able to look into this?

leonardocustodio avatar Feb 17 '24 22:02 leonardocustodio