Skip to content

[SignalR] [Java] Log 'WebSocket stopped' once #43532

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

Merged
merged 2 commits into from
Jan 24, 2023
Merged

Conversation

BrennanConroy
Copy link
Member

Noticed "WebSocket connection stopped." being logged 4 times when calling hubConnection.Stop().blockingAwait();

This was because we were returning the Completable from doOnEvent which if subscribed to will repeat per subscription. Plus, we were returning the stop task directly which would also repeat itself per subscription, and we were subscribing to it ourselves first to make sure it was a hot-observable.

@BrennanConroy BrennanConroy added area-signalr Includes: SignalR clients and servers feature-client-java Related to the SignalR Java client labels Aug 24, 2022
@BrennanConroy BrennanConroy changed the title [SignalR] [Java] Log WebSocket stopped once [SignalR] [Java] Log 'WebSocket stopped' once Aug 24, 2022
@@ -82,7 +82,9 @@ public void setOnClose(TransportOnClosedCallback onCloseCallback) {

@Override
public Completable stop() {
return webSocketClient.stop().doOnEvent(t -> logger.info("WebSocket connection stopped."));
Completable stop = webSocketClient.stop();
stop.onErrorComplete().subscribe(() -> logger.info("WebSocket connection stopped."));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to write a test that we're no longer writing this four times?

@BrennanConroy BrennanConroy merged commit 4b66d40 into main Jan 24, 2023
@BrennanConroy BrennanConroy deleted the brecon/javalog branch January 24, 2023 00:09
@ghost ghost added this to the 8.0-preview1 milestone Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers feature-client-java Related to the SignalR Java client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants