-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add reconnected handler to tendermint websocket client #1201
Conversation
2f7b752
to
9352aa1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good direction. Let's keep the scope to Tendermint only and create a new ticket for Ethereum
const request = createJsonRpcRequest("subscribe", { query: query }); | ||
const producer = new RpcEventProducer(request, this.socket); | ||
const stream = Stream.create(producer); | ||
this.subscriptionStreams.set(query, stream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sets subscriptionStreams[subscriptionStreams]
to a new reference. The old stream the caller got via const eventStream = this.client.listen(req);
will not change, so the new events do not arrive.
Also this re-establishes subscribtions that nobody listens to anymore (where the original producer was stopped).
My feeling is that in public listen(request: JsonRpcRequest): Stream<SubscriptionEvent> {
there needs to be a producer (maybe a wrapper around RpcEventProducer
) which survives the reconnect and routes events from different sources.
9352aa1
to
9b03cad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Any chance to test this? At least manually
@@ -131,6 +131,40 @@ class RpcEventProducer implements Producer<SubscriptionEvent> { | |||
} | |||
} | |||
|
|||
class ReconnectingRpcEventProducer implements Producer<SubscriptionEvent> { | |||
public stopped: boolean = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can become private, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks, I originally had the check outside the class.
@webmaster128 I’ll have a think about tests and then convert this to a non-draft PR. |
86cff85
to
a1c20f0
Compare
a1c20f0
to
cf1fb7c
Compare
Closes #1200
I’m a little unclear on the acceptance criteria for this issue, so opening this draft PR now to get feedback. Is this basically what we need or is there something I’ve missed?