client constantly reconnecting

2020-02-10 09:18发布

问题:

My .net application which connects to signalr hub is constantly reconnecting.

This problem only occurs on certain other corporate networks which makes me believe something is being blocked. I've tried to use the jabbr.net website from the same network and this doesn't work either (in chrome).

How can i trace/fix this issue?

回答1:

I think you're experiencing this issue https://github.com/SignalR/SignalR/pull/1553. We're working on a fix for it. The issue happens when the server sent events request times out but the actual http requests is still going. What then happens is that the longpolling transport and server sent events http requests fight for the connection.

To workaround this you can specify the LongPollingTransport specifically. We'll look at fixing this for the next release.



回答2:

For your server, in your web.config's system.diagnostics section add:

<sharedListeners>
  <add name="SignalR" 
       type="System.Diagnostics.TextWriterTraceListener" 
       initializeData="signalr.log.txt" />
</sharedListeners>

For your client (I'm assuming .net C#), its logging is via Debug.Writes. Also, I'd recommend hooking into the Error handler for your connection.

If your using a JS client you can turn logging on via

// Non dynamically made connection
connection.logging = true;
// Dynamically made connection
$.connection.hub.logging = true

Hope this helps!