SignalR always downgrades to long polling

1

I've created a new webservice using SignalR.Core which properly negotiates to use WebSockets. I also added it to an existing website, but it fails to negotiate both WebSockets and ServerSentEvents, so will always downgrade to use LongPolling.

Both projects target .NET v4.7.1, running on IIS Express 10. The client is a UWP app using the SignalR.Client library.

Does anyone know what I'm missing?

Client:

08:46:25.9067539 - null - ChangeState(Disconnected, Connecting)
08:46:28.4516671 - 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 - WS Connecting to: ws://192.168.0.84:8080/signalr/connect?clientProtocol=1.4&transport=webSockets&connectionData=[{"Name":"SyncHub"}]&connectionToken=GsZKYTf9rwH3NqngtHe5f6eUEcHRqlGYsBDkC2g43FOZs8zP%2FJg%2Fhld1fdm9iO91yPBoxNIqY7N%2FlnlJDCSfFwK8YTnJNztxRVS5aUPt9G4KrIYEpMNNwyucyHILDMqr
08:46:28.6707519 - 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 - Auto: Failed to connect to using transport webSockets. System.Exception: Internal server error (500). (Exception from HRESULT: 0x801901F4)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.SignalR.Client.Transports.WebSocketTransport.<OpenWebSocket>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.SignalR.Client.Transports.WebSocketTransport.<StartWebSocket>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNet.SignalR.Client.Transports.WebSocketTransport.<Start>d__14.MoveNext()
08:46:28.7516001 - 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 - SSE: GET http://192.168.0.84:8080/signalr/connect?clientProtocol=1.4&transport=serverSentEvents&connectionData=[{"Name":"SyncHub"}]&connectionToken=GsZKYTf9rwH3NqngtHe5f6eUEcHRqlGYsBDkC2g43FOZs8zP%2FJg%2Fhld1fdm9iO91yPBoxNIqY7N%2FlnlJDCSfFwK8YTnJNztxRVS5aUPt9G4KrIYEpMNNwyucyHILDMqr
08:46:33.7643871 - 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 - Auto: Failed to connect to using transport serverSentEvents. System.TimeoutException: Transport timed out trying to connect
08:46:33.7763838 - 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 - LP Connect: http://192.168.0.84:8080/signalr/connect?clientProtocol=1.4&transport=longPolling&connectionData=[{"Name":"SyncHub"}]&connectionToken=GsZKYTf9rwH3NqngtHe5f6eUEcHRqlGYsBDkC2g43FOZs8zP%2FJg%2Fhld1fdm9iO91yPBoxNIqY7N%2FlnlJDCSfFwK8YTnJNztxRVS5aUPt9G4KrIYEpMNNwyucyHILDMqr
08:46:33.9198908 - 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 - LP: OnMessage({"C":"d-555200CA-B,0|C,0|D,2","S":1,"M":[]})
08:46:33.9484163 - 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 - LP Poll: http://192.168.0.84:8080/signalr/poll?clientProtocol=1.4&transport=longPolling&connectionData=[{"Name":"SyncHub"}]&connectionToken=GsZKYTf9rwH3NqngtHe5f6eUEcHRqlGYsBDkC2g43FOZs8zP%2FJg%2Fhld1fdm9iO91yPBoxNIqY7N%2FlnlJDCSfFwK8YTnJNztxRVS5aUPt9G4KrIYEpMNNwyucyHILDMqr&messageId=d-555200CA-B%2C0%7CC%2C0%7CD%2C2
08:46:34.0659311 - 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 - ChangeState(Connecting, Connected)

Server:

SignalR.PerformanceCounterManager Error: 0 : Performance counter failed to load: System.InvalidOperationException: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.
   at System.Diagnostics.PerformanceCounter.InitializeImpl()
   at System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName, Boolean readOnly)

...

SignalR.Transports.TransportHeartBeat Information: 0 : Connection 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 is New.
SignalR.Transports.ServerSentEventsTransport Verbose: 0 : Sending outgoing message. Connection id: 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341, transport: ServerSentEventsTransport, message: data: {"C":"d-555200CA-B,0|C,0|D,1","S":1,"M":[]}

SignalR.Transports.ServerSentEventsTransport Verbose: 0 : DrainWrites(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.ServerSentEventsTransport Information: 0 : CompleteRequest (1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.TransportHeartBeat Verbose: 0 : Connection 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 exists. Closing previous connection.
SignalR.Transports.ServerSentEventsTransport Information: 0 : End(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.ServerSentEventsTransport Verbose: 0 : Cancel(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.ServerSentEventsTransport Verbose: 0 : DrainWrites(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.ServerSentEventsTransport Information: 0 : CompleteRequest (1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.LongPollingTransport Verbose: 0 : DrainWrites(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.LongPollingTransport Information: 0 : CompleteRequest (1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
Client Connected: 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341
SignalR.Transports.TransportHeartBeat Verbose: 0 : Connection 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 exists. Closing previous connection.
SignalR.Transports.LongPollingTransport Information: 0 : End(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/1/ROOT-1-131551227438578638): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Diagnostics.Debug\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Diagnostics.Debug.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
SignalR.HubDispatcher Verbose: 0 : Sending hub invocation result to connection 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 using transport LongPollingTransport
'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/1/ROOT-1-131551227438578638): Loaded 'Microsoft.AspNet.SignalR.Hubs.TypedClientBuilder'. 
SignalR.Transports.LongPollingTransport Verbose: 0 : DrainWrites(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.LongPollingTransport Information: 0 : CompleteRequest (1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/1/ROOT-1-131551227438578638): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Collections.Concurrent\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Collections.Concurrent.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
SignalR.Transports.TransportHeartBeat Verbose: 0 : Connection 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 exists. Closing previous connection.
SignalR.Transports.LongPollingTransport Information: 0 : End(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.LongPollingTransport Verbose: 0 : DrainWrites(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.LongPollingTransport Information: 0 : CompleteRequest (1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/1/ROOT-1-131551227438578638): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Threading\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
SignalR.Transports.TransportHeartBeat Verbose: 0 : Connection 1cf03bfa-cfa6-45b2-b3f7-a342c17c8341 exists. Closing previous connection.
SignalR.Transports.LongPollingTransport Information: 0 : End(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/1/ROOT-1-131551227438578638): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Globalization\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Globalization.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
The thread 0x2ca0 has exited with code 0 (0x0).
The thread 0x151c has exited with code 0 (0x0).
SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
SignalR.Transports.LongPollingTransport Verbose: 0 : DrainWrites(1cf03bfa-cfa6-45b2-b3f7-a342c17c8341)
c#
.net
websocket
signalr
asked on Stack Overflow Nov 13, 2017 by Ben Catterall • edited Nov 14, 2017 by Ben Catterall

1 Answer

2

The issue was the target framework for httpRuntime in web.config.

It was set to <httpRuntime/>. Changing it to <httpRuntime targetFramework="4.7.1"/> allows websockets to be successfully negotiated.

I finally found the answer here.

answered on Stack Overflow Nov 14, 2017 by Ben Catterall • edited Nov 15, 2017 by Ben Catterall

User contributions licensed under CC BY-SA 3.0