Skip to content

Check HubConnection state before running invoke logic #4400

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 3 commits into from
Jan 15, 2019

Conversation

mikaelm12
Copy link
Contributor

@mikaelm12 mikaelm12 commented Dec 4, 2018

Before calling methods that require the HubConnection to be connected we run a simple connection state check like
https://github.com/aspnet/AspNetCore/blob/e310ccac7b30e901f657f81c86c4048fecfedf7b/src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/HubConnection.java#L464-L466

Addresses #4393

Description

Before being able to send invocations from a SignalR hub, it's important that we ensure that the current HubConnection is active and in the connected state. If the HubConnection isn't connected we should fail immediately without attmepting to send any invocations. Otherwise we could run into a case where users can write the connected

HubConnection hubConnection = new HubConnectionBuilder.create("Some hub url");
// There should be an awaited call to start before invoke.
hubConnection.invoke(String.class, "hubMethod", "arg")

Customer Impact

With this change, when a customer tries to invoke a hub method when their client is not connected, they will get a helpful error message letting them know that they are in the disconnected state.

Regression

N/A

Risk

Low. This is purely a defensive change. We woul be adding a check to the HubConnection state before continuing to the rest of the invoke logic to ensure that we fail fast with a helpful error message. This also has an associate test.

@mikaelm12 mikaelm12 added the area-signalr Includes: SignalR clients and servers label Dec 4, 2018
@mikaelm12 mikaelm12 requested a review from muratg December 4, 2018 22:06
@mikaelm12 mikaelm12 added the Servicing-consider Shiproom approval is required for the issue label Dec 4, 2018
@muratg
Copy link
Contributor

muratg commented Dec 4, 2018

@mikaelm12 can you also add the shiproom template? (You can find a copy from #4403)

@muratg muratg added this to the 2.2.2 milestone Dec 4, 2018
@mikaelm12
Copy link
Contributor Author

Added the template

@vivmishra vivmishra added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Dec 6, 2018
@vivmishra
Copy link

Approved for 2.2.2

Copy link
Contributor

@muratg muratg left a comment

Choose a reason for hiding this comment

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

Buid checks seem to be failing.

@mikaelm12
Copy link
Contributor Author

The failure was for an IIS Functional test. An unrelated test failure.

Starting test execution, please wait...
2018-12-04T22:55:50.8997274Z   [xUnit.net 00:00:17.97]     Microsoft.AspNetCore.Server.IIS.FunctionalTests.AppOfflineTests.AppOfflineDroppedWhileSiteFailedToStartInRequestHandler_SiteStops_InProcess [SKIP]
2018-12-04T22:55:51.8627524Z   Skipped  Microsoft.AspNetCore.Server.IIS.FunctionalTests.AppOfflineTests.AppOfflineDroppedWhileSiteFailedToStartInRequestHandler_SiteStops_InProcess
2018-12-04T22:57:20.4801986Z   [xUnit.net 00:01:47.51]     Microsoft.AspNetCore.Server.IIS.FunctionalTests.AppOfflineTests.AppOfflineDroppedWhileSiteStarting_SiteShutsDown_InProcess [FAIL]
2018-12-04T22:57:20.4848481Z   Failed   Microsoft.AspNetCore.Server.IIS.FunctionalTests.AppOfflineTests.AppOfflineDroppedWhileSiteStarting_SiteShutsDown_InProcess
2018-12-04T22:57:20.4848649Z   Error Message:
2018-12-04T22:57:20.4848762Z    Assert.Equal() Failure
2018-12-04T22:57:20.4848871Z   Expected: 0
2018-12-04T22:57:20.4848956Z   Actual:   -1073740767

@dougbu
Copy link
Contributor

dougbu commented Jan 15, 2019

Not sure how we ship our Java binaries. If necessary, please update the 2.2.2 section of eng/PatchConfig.props: https://github.com/aspnet/Extensions/blob/d8407116d183debaadb801c0cbc41d65927999d6/eng/PatchConfig.props#L7-L10

@mikaelm12 mikaelm12 force-pushed the mikaelm12/ConnectionStateCheck branch from 9bdcedc to e427c98 Compare January 15, 2019 01:02
@@ -27,6 +27,7 @@ Later on, this will be checked using this condition:
</PropertyGroup>
<PropertyGroup Condition=" '$(VersionPrefix)' == '2.2.2' ">
<PackagesInPatch>
java:signalr;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@natemcmaster This look okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Double check artifacts/ for the .jar file to make sure it worked.

@mikaelm12 mikaelm12 force-pushed the mikaelm12/ConnectionStateCheck branch from e427c98 to 9c49061 Compare January 15, 2019 18:07
@mikaelm12 mikaelm12 force-pushed the mikaelm12/ConnectionStateCheck branch from 9c49061 to 2666c6e Compare January 15, 2019 18:36
@mikaelm12 mikaelm12 merged commit 852d890 into release/2.2 Jan 15, 2019
@natemcmaster natemcmaster deleted the mikaelm12/ConnectionStateCheck branch January 18, 2019 19:16
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 Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants