SignalR Server:
- IIS ASP.Net Core 8.0,
- Microsoft.AspNetCore.SignalR 1.2.0,
- Microsoft.AspNetCore.SignalR.Core 1.2.0,
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson 6.0.9
Javascript (Browser) successfully made SignalR connection
Commented AllowAnyOrigin because it can not be used at the same time with AllowCredentials.
Commented [Authorize] when defining RFactorHub
services.AddCors(options => {
options.AddPolicy(QmosPolicy, builder => {
builder //.AllowAnyOrigin()
.AllowAnyMethod()
.AllowCredentials()
.AllowAnyHeader();
});
});
services.AddSignalR(hubOptions => {
hubOptions.MaximumReceiveMessageSize = long.MaxValue;
}).AddNewtonsoftJsonProtocol();
//[Authorize] //because of RFactor Client in .NET Framework 4.8
public class RFactorHub : HubBase {
...
}
SignalR Client 1 successfully made SignalR connection
- IIS ASP.NET 4.8,
- Microsoft.AspNetCore.SignalR.Client 8.0.0.0,
- Microsoft.AspNetCore.SignalR.Client.Core 8.0.0.0,
- Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson 6.0.9
Connection = new HubConnectionBuilder()
.AddNewtonsoftJsonProtocol()
.WithUrl("http://localhost/QMOSRFactor/rfactor")
.WithAutomaticReconnect()
.Build();
SignalR Client 2 failed to make SignalR connection.
- Windows C# Desktop UI App .NET Framework 4.8,
- Microsoft.AspNetCore.SignalR.Client 8.0.0.0,
- Microsoft.AspNetCore.SignalR.Client.Core 8.0.0.0,
- Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson 6.0.9
Connection = new HubConnectionBuilder()
.WithUrl("http://localhost/QMOSRFactor/rfactor", HttpTransportType.WebSockets)
.ConfigureLogging(logging => {
logging.SetMinimumLevel(LogLevel.Trace);
logging.AddConsole();
})
.WithAutomaticReconnect()
.AddNewtonsoftJsonProtocol()
.Build();
The call to
await Connection.StartAsync();
never return. It created the following log. It made the connection and sent ping messages. But the call never return.
My email net.wang@quadinfotech.com
My phone: 416-786-0319
I am available on Microsoft Teams / Zoom to share screen to debug.
One project used 3rd party library which runs only on Windows UI App .NET Framework 4.8. We can't host it in IIS as ASP.NET 4.8. We have to fix this SignalR connection issue for release.
'RFactorClient1.exe' (CLR v4.0.30319: RFactorClient1.exe): Loaded 'C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\Remote Debugger\x86\Runtime\Microsoft.VisualStudio.Debugger.Runtime.Desktop.dll'.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[42]
Waiting on Connection Lock in StartAsyncInner (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:261).
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[80]
The HubConnection is attempting to transition from the Disconnected state to the Connecting state.
'RFactorClient1.exe' (CLR v4.0.30319: RFactorClient1.exe): Loaded 'C:\my\projects\QMOS Project\QMOS-Misc-Git\RFactorClient1\bin\Debug\Microsoft.Extensions.Features.dll'. Symbol loading disabled by Include/Exclude setting.
'RFactorClient1.exe' (CLR v4.0.30319: RFactorClient1.exe): Loaded 'C:\my\projects\QMOS Project\QMOS-Misc-Git\RFactorClient1\bin\Debug\System.IO.Pipelines.dll'. Symbol loading disabled by Include/Exclude setting.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[41]
Starting HubConnection.
'RFactorClient1.exe' (CLR v4.0.30319: RFactorClient1.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Symbol loading disabled by Include/Exclude setting.
'RFactorClient1.exe' (CLR v4.0.30319: RFactorClient1.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.InteropServices.RuntimeInformation\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.InteropServices.RuntimeInformation.dll'. Module was built without symbols.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1]
Starting HttpConnection.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[8]
Establishing connection with server at 'http://localhost/QMOSRFactor/rfactor'.
trce: Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler[1]
Sending HTTP request POST 'http://localhost/QMOSRFactor/rfactor/negotiate?negotiateVersion=1'.
'RFactorClient1.exe' (CLR v4.0.30319: RFactorClient1.exe): Loaded 'C:\my\projects\QMOS Project\QMOS-Misc-Git\RFactorClient1\bin\Debug\System.Numerics.Vectors.dll'. Symbol loading disabled by Include/Exclude setting.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[9]
Established connection 'bnxI_3NDy-yJWYV8ikjrQw' with the server.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7]
Starting transport 'WebSockets' with Url: http://localhost/QMOSRFactor/rfactor.
info: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[1]
Starting transport. Transfer mode: Text. Url: 'ws://localhost/QMOSRFactor/rfactor?id=8yZcjiS-3ht2arD0wP4SXQ'.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[19]
Started transport.
dbug: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[18]
Transport 'WebSockets' started.
info: Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3]
HttpConnection Started.
info: Microsoft.AspNetCore.SignalR.Client.HubConnection[24]
Using HubProtocol 'json v1'.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[28]
Sending Hub Handshake.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
Received message from application. Payload size: 32.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
Message received. Type: Text, size: 3, EndOfMessage: True.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[39]
Handshake with server complete.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[59]
Sending PingMessage message.
'RFactorClient1.exe' (CLR v4.0.30319: RFactorClient1.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Symbol loading disabled by Include/Exclude setting.
'RFactorClient1.exe' (CLR v4.0.30319: RFactorClient1.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll'. Symbol loading disabled by Include/Exclude setting.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
Received message from application. Payload size: 11.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[60]
Sending PingMessage message completed.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[47]
Receive loop starting.
info: Microsoft.AspNetCore.SignalR.Client.HubConnection[44]
HubConnection started.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[80]
The HubConnection is attempting to transition from the Connecting state to the Connected state.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[20]
Releasing Connection Lock in StartAsyncInner (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:294).
The thread 31388 has exited with code 0 (0x0).
The thread 31324 has exited with code 0 (0x0).
The thread 31328 has exited with code 0 (0x0).
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
Message received. Type: Text, size: 11, EndOfMessage: True.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[56]
Processing 11 byte message from server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[26]
Resetting keep-alive timer, received a message from the server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[31]
Received a ping message.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[61]
Acquired the Connection Lock in order to ping the server.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[59]
Sending PingMessage message.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[60]
Sending PingMessage message completed.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[20]
Releasing Connection Lock in RunTimerActions (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:2157).
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
Received message from application. Payload size: 11.
The thread 15348 has exited with code 0 (0x0).
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[61]
Acquired the Connection Lock in order to ping the server.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[59]
Sending PingMessage message.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[60]
Sending PingMessage message completed.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[20]
Releasing Connection Lock in RunTimerActions (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:2157).
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
Received message from application. Payload size: 11.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
Message received. Type: Text, size: 11, EndOfMessage: True.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[56]
Processing 11 byte message from server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[26]
Resetting keep-alive timer, received a message from the server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[31]
Received a ping message.
The thread 29776 has exited with code 0 (0x0).
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[61]
Acquired the Connection Lock in order to ping the server.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[59]
Sending PingMessage message.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[60]
Sending PingMessage message completed.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[20]
Releasing Connection Lock in RunTimerActions (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:2157).
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
Received message from application. Payload size: 11.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
Message received. Type: Text, size: 11, EndOfMessage: True.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[56]
Processing 11 byte message from server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[26]
Resetting keep-alive timer, received a message from the server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[31]
Received a ping message.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[61]
Acquired the Connection Lock in order to ping the server.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[59]
Sending PingMessage message.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[60]
Sending PingMessage message completed.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[20]
Releasing Connection Lock in RunTimerActions (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:2157).
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
Received message from application. Payload size: 11.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
Message received. Type: Text, size: 11, EndOfMessage: True.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[56]
Processing 11 byte message from server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[26]
Resetting keep-alive timer, received a message from the server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[31]
Received a ping message.
The thread 1156 has exited with code 0 (0x0).
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[61]
Acquired the Connection Lock in order to ping the server.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[59]
Sending PingMessage message.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[60]
Sending PingMessage message completed.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[20]
Releasing Connection Lock in RunTimerActions (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:2157).
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[13]
Received message from application. Payload size: 11.
dbug: Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[12]
Message received. Type: Text, size: 11, EndOfMessage: True.
dbug: Microsoft.AspNetCore.SignalR.Client.HubConnection[56]
Processing 11 byte message from server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[26]
Resetting keep-alive timer, received a message from the server.
trce: Microsoft.AspNetCore.SignalR.Client.HubConnection[31]
Received a ping message.
The thread 31164 has exited with code 0 (0x0).