1

We have several clients connected to a server via signalr. Lately we found a strange behavior where it fails to deliver messages from server to clients after we have done a stop and start site from IIS. (Not stopping IIS itself, only the site). When stopping and starting from the IIS does not fire disconnect from the clients and signalr in built keepalive message keeps on going. Also we implemneted a similar keepalive method by yourself which returns a Boolean value, which also works even after IIS stop/start.

2017-04-19 08:55:28.0875 DEBUG [TID:20 TName:]  03:25:28.0875474 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:55:38.0385 DEBUG [TID:19 TName:]  03:25:38.0385943 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:55:48.0696 DEBUG [TID:20 TName:]  03:25:48.0696881 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:55:58.1000 DEBUG [TID:19 TName:]  03:25:58.1000834 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:55:59.2373 DEBUG [TID:20 TName:]  03:25:59.2373993 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({"C":"d-F7251D27-B,0|C,8|D,0","M":[{"H":"ConnectorHub","M":"IsConnectionAlive","A":[true]}]})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:55:59.2373 DEBUG [TID:20 TName:]  03:25:59.2384003 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({"I":"21"})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:56:08.1654 DEBUG [TID:13 TName:]  03:26:08.1654216 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:56:18.0708 DEBUG [TID:20 TName:]  03:26:18.0708681 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:56:28.2090 DEBUG [TID:13 TName:]  03:26:28.2090847 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:56:38.1200 DEBUG [TID:20 TName:]  03:26:38.1200707 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:56:48.2138 DEBUG [TID:13 TName:]  03:26:48.2138197 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:56:58.2533 DEBUG [TID:20 TName:]  03:26:58.2533306 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:57:08.4435 DEBUG [TID:13 TName:]  03:27:08.4435264 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:57:18.2721 DEBUG [TID:20 TName:]  03:27:18.2721034 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})
 (Util.SignalrTraceWriter.Write) 
2017-04-19 08:57:28.4231 DEBUG [TID:13 TName:]  03:27:28.4231487 - 68e2ca39-9b7d-4652-904f-6fa53b0e616f - WS: OnMessage({})

In above trace IIS stop happens around 08:54:50 and start happens around 08:55:30. You can see that no disconnection is fired and both keepalive and method implemented by us communicate perfectly fine.

The issue is that after IIS stop/start messages that contains entities (defined by us) are failed to deliver. It tries to the same connection id that we are sending the IsConnectionAlive callback. But it never reaches the client. The difference between these both are the IsConnectionAlive only returns a boolean value as the parameter where other sends an entity as the parameter.

2017-04-19 08:56:41.5224 DEBUG  SignalRHubHelper Sent job [192453] to Connector , connection id : 68e2ca39-9b7d-4652-904f-6fa53b0e616f (SignalRHubHelper) 

The above is the log line from the server where it sends the entity.

Strangely we found that by enabling backplane (sql backplane) it manages to send messages with the entity even after IIS stop/start. Although there is a backplane there is no other servers connected to the backplane. What can be the cause for this behavior and what would be the case for not delivering messages after IIS stop/start with an entity.

Janitha Tennakoon
  • 856
  • 11
  • 40
  • For first 10 seconds, SignalR tries reaching server. But failing to reconnect within that 10 secs, will lead to disconnect. That's what their documents says. For your case, you need to save all messages in database when they arrive to server and push it to the respective receiver afterwards. And also needs to handle disconnection properly (caching of messages or don't allow client to send messages when connection is in reconnecting, connecting or disconnected state) at client side. – Ketan Modi Apr 19 '17 at 03:47
  • I stops the IIS site for more than 10 seconds, but the clients does not fire disconnect. And its not that client to server messages that are failing, it is from server to the client. And even server to client messages are successful if it returns only a primitive data type. – Janitha Tennakoon Apr 19 '17 at 03:54
  • Strange! Have you tried parsing your data to JSON before invoking clients? – Ketan Modi Apr 19 '17 at 03:58
  • Just a side note, Are you using IIS 8+? SignalR has problems with older IIS. – Ketan Modi Apr 19 '17 at 03:59
  • Yes, IIS 8.5 with SignalR version 2.2.1. We are sending all the messages in JSON. – Janitha Tennakoon Apr 19 '17 at 04:00

0 Answers0