-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and servers
Milestone
Description
Describe the bug
A clear and concise description of what the bug is.
When I use Java client, it's easy to get 2 kinds of error on server:
Missing required property 'protocol'. and System.IO.InvalidDataException: Missing required property 'type'.
To Reproduce
Use this code to start/stop clients:
import com.microsoft.signalr.HubConnection;
import com.microsoft.signalr.HubConnectionBuilder;
import io.reactivex.Single;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class Chat {
public static HubConnection create(boolean service)
{
if (service) {
HubConnection hubConnection = HubConnectionBuilder
// .create("http://localhost:5000/chat")
.create("http://localhost:8080/client/?hub=hub")
.withAccessTokenProvider(Single.defer(() -> {
return Single.just("...");
}))
.build();
return hubConnection;
} else {
HubConnection hubConnection = HubConnectionBuilder
.create("http://localhost:5000/chat")
.build();
return hubConnection;
}
}
public static void main(String[] args) throws Exception {
ThreadPoolExecutor executor = new ThreadPoolExecutor(100, 200, 300,
TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(3),
new ThreadPoolExecutor.CallerRunsPolicy());
HubConnection hubConnection = create(false);
for(int i=0;i<10;i++) start(executor, hubConnection);
for(int i=0;i<10;i++) stop(executor, hubConnection);
}
public static void stop(ThreadPoolExecutor executor, HubConnection hubConnection) {
executor.execute(() -> {
while (true) {
try {
hubConnection.stop();
Thread.sleep((int) (Math.random() * 500));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public static void start(ThreadPoolExecutor executor, HubConnection hubConnection) {
executor.execute(() -> {
while (true) {
try {
hubConnection.start();
Thread.sleep((int) (Math.random() * 50));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
Exceptions (if any)
System.IO.InvalidDataException: Missing required property 'protocol'. Message content: {"type":6}
at Microsoft.AspNetCore.SignalR.Protocol.HandshakeProtocol.TryParseRequestMessage(ReadOnlySequence`1& buffer, HandshakeRequestMessage& requestMessage)
at Microsoft.AspNetCore.SignalR.HubConnectionContext.HandshakeAsync(TimeSpan timeout, IReadOnlyList`1 supportedProtocols, IHubProtocolResolver protocolResolver, IUserIdProvider userIdProvider, Boolean enableDetailedErrors)
and
System.IO.InvalidDataException: Missing required property 'type'.
at Microsoft.AspNetCore.SignalR.Protocol.JsonHubProtocol.ParseMessage(Utf8BufferTextReader textReader, IInvocationBinder binder)
at Microsoft.AspNetCore.SignalR.Protocol.JsonHubProtocol.TryParseMessage(ReadOnlySequence`1& input, IInvocationBinder binder, HubMessage& message)
at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.DispatchMessagesAsync(HubConnectionContext connection)
at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.RunHubAsync(HubConnectionContext connection)
Further technical details
- ASP.NET Core version
- Include the output of
dotnet --info - The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version
Signalr java client:
<dependency>
<groupId>com.microsoft.signalr</groupId>
<artifactId>signalr</artifactId>
<version>5.0.0-preview.3.20215.14</version>
</dependency>
.NET SDK (reflecting any global.json):
Version: 5.0.100-preview.5.20279.10
Commit: 8139f1b74e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.100-preview.5.20279.10\
Host (useful for support):
Version: 5.0.0-preview.5.20278.1
Commit: 4ae4e2fe08
.NET SDKs installed:
2.1.700 [C:\Program Files\dotnet\sdk]
2.2.207 [C:\Program Files\dotnet\sdk]
3.1.200 [C:\Program Files\dotnet\sdk]
5.0.100-preview.5.20279.10 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-preview.5.20279.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-preview.5.20278.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-preview.5.20278.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
IDE:
IntelliJ IDEA 2020.1.2 (Community Edition)
Build #IC-201.7846.76, built on June 1, 2020
Runtime version: 11.0.7+10-b765.53 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 2014M
Cores: 4
Metadata
Metadata
Assignees
Labels
area-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and servers