-
Notifications
You must be signed in to change notification settings - Fork 217
Resubscribe channels only when reconnecting #548
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,18 +224,18 @@ protected void initChannel(SocketChannel ch) { | |
} | ||
reconnFailEmitters.forEach(emitter -> emitter.onNext(t)); | ||
}) | ||
.doOnComplete(() -> { | ||
LOG.warn("Resubscribing channels"); | ||
resubscribeChannels(); | ||
|
||
connectionSuccessEmitters.forEach(emitter -> emitter.onNext(new Object())); | ||
}); | ||
.doOnComplete(() -> connectionSuccessEmitters.forEach(emitter -> emitter.onNext(new Object()))); | ||
} | ||
|
||
private void scheduleReconnect() { | ||
LOG.info("Scheduling reconnection"); | ||
webSocketChannel.eventLoop().schedule( | ||
() -> connect().subscribe(), | ||
() -> connect().subscribe( | ||
() -> { | ||
LOG.warn("Resubscribing channels"); | ||
resubscribeChannels(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also needs to call the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we move over to PublishSubject for reconnFailEmitters and connectionSuccessEmitters? I know its a little out of scope, but would be nice. Maybe emit the exchange too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Funnily enough, I just suggested that on another review! Yes, that seems sensible - it means that subscriptions to those observables could persist between manual reconnects. |
||
} | ||
), | ||
retryDuration.toMillis(), | ||
TimeUnit.MILLISECONDS); | ||
} | ||
|
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.
Could you check that this still works for exchanges such as Binance where channel subscriptions are made on connection?