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

[Bug] Pubsub backend reconnect doesn't work #105

Closed
leruaa opened this issue Jan 12, 2024 · 1 comment · Fixed by #107
Closed

[Bug] Pubsub backend reconnect doesn't work #105

leruaa opened this issue Jan 12, 2024 · 1 comment · Fixed by #107
Labels
bug Something isn't working

Comments

@leruaa
Copy link
Contributor

leruaa commented Jan 12, 2024

Component

pubsub

What version of Alloy are you on?

v0.1.0 (commit 50e38e8)

Operating System

Linux

Describe the bug

I'm using pubsub to subscribe to neHeads and logs via my Alchemy provider, and a get this error a few times a day:

ERROR WS connection error while receiving a response err=WebSocket protocol error: Connection reset without closing handshake

immediately followed by these logs:

 INFO Reconnecting pubsub service backend.
DEBUG Draining old backend to_handle
DEBUG Reissuing pending requests count=0
DEBUG Re-starting active subscriptions count=2

And that's it, I don't receive notifications anymore after that.

After adding more traces I noticed that new subscriptions are sent to the server, but the responses are not handled, because the reconnect logic doesn't add back in-flight request, and it's needed:

fn handle_item(&mut self, item: PubSubItem) -> TransportResult<()> {
match item {
PubSubItem::Response(resp) => match self.in_flights.handle_response(resp) {
Some((server_id, in_flight)) => self.handle_sub_response(in_flight, server_id),
None => Ok(()),
},
PubSubItem::Notification(notification) => {
self.subs.notify(notification);
Ok(())
}
}
}

Another issue: Looking at PubSubService::reconnect(), I noticed that all server ids are dropped, leading to close the connection between the backend and the frontend.

@leruaa leruaa added the bug Something isn't working label Jan 12, 2024
@leruaa
Copy link
Contributor Author

leruaa commented Jan 12, 2024

I'm testing "dirty" fix that seems to work (4 connections lost due to "Connection reset" and 4 successful reconnects in about 12 hours)

I'll do a PR tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant