diff --git a/eng/PatchConfig.props b/eng/PatchConfig.props
index d6bb89f4ee..fb36465bc8 100644
--- a/eng/PatchConfig.props
+++ b/eng/PatchConfig.props
@@ -20,8 +20,11 @@ Later on, this will be checked using this condition:
@aspnet/signalr;
+ Microsoft.AspNetCore.AspNetCoreModuleV2;
Microsoft.AspNetCore.Authentication.Google;
Microsoft.AspNetCore.Http;
+ Microsoft.AspNetCore.Server.IIS;
+ java:signalr;
diff --git a/src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/HubConnection.java b/src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/HubConnection.java
index 2ad841d798..0bb3c22db5 100644
--- a/src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/HubConnection.java
+++ b/src/SignalR/clients/java/signalr/src/main/java/com/microsoft/signalr/HubConnection.java
@@ -465,7 +465,7 @@ public class HubConnection {
*/
public void send(String method, Object... args) {
if (hubConnectionState != HubConnectionState.CONNECTED) {
- throw new RuntimeException("The 'send' method cannot be called if the connection is not active");
+ throw new RuntimeException("The 'send' method cannot be called if the connection is not active.");
}
InvocationMessage invocationMessage = new InvocationMessage(null, method, args);
@@ -483,6 +483,10 @@ public class HubConnection {
*/
@SuppressWarnings("unchecked")
public Single invoke(Class returnType, String method, Object... args) {
+ if (hubConnectionState != HubConnectionState.CONNECTED) {
+ throw new RuntimeException("The 'invoke' method cannot be called if the connection is not active.");
+ }
+
String id = connectionState.getNextInvocationId();
InvocationMessage invocationMessage = new InvocationMessage(id, method, args);
diff --git a/src/SignalR/clients/java/signalr/src/test/java/com/microsoft/signalr/HubConnectionTest.java b/src/SignalR/clients/java/signalr/src/test/java/com/microsoft/signalr/HubConnectionTest.java
index 95f4e2c191..894edf323d 100644
--- a/src/SignalR/clients/java/signalr/src/test/java/com/microsoft/signalr/HubConnectionTest.java
+++ b/src/SignalR/clients/java/signalr/src/test/java/com/microsoft/signalr/HubConnectionTest.java
@@ -1119,7 +1119,16 @@ class HubConnectionTest {
assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
Throwable exception = assertThrows(RuntimeException.class, () -> hubConnection.send("inc"));
- assertEquals("The 'send' method cannot be called if the connection is not active", exception.getMessage());
+ assertEquals("The 'send' method cannot be called if the connection is not active.", exception.getMessage());
+ }
+
+ @Test
+ public void cannotInvokeBeforeStart() {
+ HubConnection hubConnection = TestUtils.createHubConnection("http://example.com");
+ assertEquals(HubConnectionState.DISCONNECTED, hubConnection.getConnectionState());
+
+ Throwable exception = assertThrows(RuntimeException.class, () -> hubConnection.invoke(String.class, "inc", "arg1"));
+ assertEquals("The 'invoke' method cannot be called if the connection is not active.", exception.getMessage());
}
@Test
@@ -1423,4 +1432,4 @@ class HubConnectionTest {
() -> hubConnection.start().timeout(1, TimeUnit.SECONDS).blockingAwait());
assertEquals("Unexpected status code returned from negotiate: 500 Internal server error.", exception.getMessage());
}
-}
\ No newline at end of file
+}