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

Is it possible to handle reconnecting internally? #551

Closed
yjhmelody opened this issue May 27, 2022 · 6 comments
Closed

Is it possible to handle reconnecting internally? #551

yjhmelody opened this issue May 27, 2022 · 6 comments
Labels
needs thought We need to resolve some questions before we can work on this

Comments

@yjhmelody
Copy link
Contributor

yjhmelody commented May 27, 2022

It's not easy to reconnect if not wrap so many code by myself.

Maybe It's good idea to try to reconnect just like polkadotjs/api

@jsdw
Copy link
Collaborator

jsdw commented May 27, 2022

The complexity with this is that if the connection is lost, any subscriptions and so on will go away, including things like watching for transaction status when submitting an extrinsic. having your own connection logic allows you to decide what to do about those things (resubscribing to anything of interest and taking into account the potential for missed information, and deciding what to do about transactions you are no longer able to monitor, for instance).

It's the sort of feature I'd like to have in subxt, but it could be quite tricky to implement, and things like waiting for extrinsics to finalize would potentially just never complete and there is afaik no good way to deal with that at the moment. Any ideas or thoughts would be welcome!

@yjhmelody
Copy link
Contributor Author

Maybe consider some behaviors to align with polkadotjs/api

@gilescope
Copy link
Contributor

gilescope commented Jun 14, 2022

For subscriptions you could just send an event indicating that the subscription had stopped and one would need to resubscribe. Then later if you add re-subscribing logic you could do that in the back and not send the event. It would be helpfult to be able to opt into having something that re-established a connection. (Or provide a reconnecting wrapper type?). That at least would work for people not using the subscriptions and using it more like a rust API to substrate.

@jsdw
Copy link
Collaborator

jsdw commented Jun 14, 2022

Thanks, definitely something to think about! I haven't forgotten about this issue; just been busy on other bits of late :)

@jsdw jsdw changed the title Support reconnection ? Is it possible to handle reconnecting internally? Jun 14, 2022
@jsdw jsdw added this to the Release 0.23 milestone Jun 14, 2022
@jsdw jsdw modified the milestones: v0.24: Tidy and Polish, v0.25 Aug 5, 2022
@jsdw jsdw modified the milestones: v0.25, v1.0 Aug 15, 2022
@jsdw jsdw added the needs thought We need to resolve some questions before we can work on this label Sep 27, 2022
@xlc
Copy link

xlc commented Feb 2, 2023

I am working on this to implement retry for ws clients https://github.com/AcalaNetwork/subway/blob/master/src/client/mod.rs

@niklasad1
Copy link
Member

This has been fixed, subxt provides a reconnecting-rpc-client behind a feature flag but everything works as intended we will make it the default one in a future release.

See https://github.com/paritytech/subxt/blob/master/subxt/examples/setup_reconnecting_rpc_client.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs thought We need to resolve some questions before we can work on this
Projects
None yet
Development

No branches or pull requests

5 participants