Skip to content

Conversation

chr15m
Copy link
Contributor

@chr15m chr15m commented Sep 28, 2025

This PR adds a new flag enableReconnect which turns on an exponential-backoff reconnection sequence for relay subscriptions. When a relay disconnects, reconnection will be attempted with a delay that gets longer with each attempt.

If enableReconnect is set to a callback function it will be called when reconnection occurs and passed the current subscription. This can be used to modify the subscription filters or e.g. the since parameter to fetch only newer events. The updated subscription will then be used.

This PR also:

Here's a simple HTML file test: reconnect-test.html.zip (put it in nostr-tools and run just build and then open it)

Fixes #491.

@fiatjaf
Copy link
Collaborator

fiatjaf commented Sep 29, 2025

Looks great. I think I created some conflicts when I merged that other PR. Can you fix them and then I'll merge (or perhaps squash will be better)?

@chr15m
Copy link
Contributor Author

chr15m commented Sep 30, 2025

Fixed, thank you!

@chr15m
Copy link
Contributor Author

chr15m commented Sep 30, 2025

I don't have a preference between squash or merge, all good.

@fiatjaf fiatjaf merged commit bc1294e into nbd-wtf:master Sep 30, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

Reconnection with exponential backoff

2 participants