I have a C# SignalR client (2.2) and ASP.NET MVC SignalR server on Azure. When a new "Entity" is created on the server side, it pushes a simple notification to the client using the following:
public static class EntityHubHelper
{
private static readonly IHubContext _hubContext = GlobalHost.ConnectionManager.GetHubContext<EntityHub>();
public static void EntityCreated(IdentityUser user, Entity entity)
{
_hubContext.Clients.User(user.UserName).EntityCreated(entity);
}
}
[Authorize]
public class EntityHub : Hub
{
// Just tracing overrides for OnConnected/OnReconnected/OnDisconnected
}
Occasionally the client or server will reconnect, which is expected, but I'm seeing cases where both reconnect (e.g. restarting web server), but then the client stops getting data.
This seems to happen after 1-2 days of no data being pushed, then finally a push that gets missed.
Our client tracing:
15/08/02 03:57:23 DEBUG SignalR: StateChanged: Connected -> Reconnecting
15/08/02 03:57:28 DEBUG SignalR: Error: System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
15/08/02 03:57:31 DEBUG SignalR: Error: System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
15/08/02 03:57:47 DEBUG SignalR: StateChanged: Reconnecting -> Connected
15/08/02 03:57:47 INFO SignalR OnReconnected
Our server tracing:
8/2/2015 3:57:57 AM [SignalR][OnReconnected] Email=correspondinguser@example.com, ConnectionId=ff4e472b-184c-49d4-a662-8b0e26da43e2
I'm using the server defaults for keepalive and timeout (10s and 30s) and it's generally using websockets (enabled on Azure, standard so no limits).
I have two questions:
(1) How is the client meant to find out that a server has been restarted in the websocket case (in which case it would lose memory of said client's existence)? Do the server's 10s/30s settings get pushed down during the initial connection, and the client decides that the server is gone after 30s?
(2) How do I debug this situation? Is there some way to prove that the client is actually still receiving keepalives so I know I have some catastrophic problem somewhere else?