Strengthened reconnect behavior with both app server and IIS outages

This commit is contained in:
Heath Volmer
2018-09-10 13:49:56 -06:00
parent a0a83a1af7
commit 1c9061cc28

View File

@@ -416,7 +416,6 @@ namespace PepperDash.Essentials
WSClient = new WebSocketClient(); WSClient = new WebSocketClient();
WSClient.URL = string.Format("wss://{0}/system/join/{1}", Config.ServerUrl, this.SystemUuid); WSClient.URL = string.Format("wss://{0}/system/join/{1}", Config.ServerUrl, this.SystemUuid);
WSClient.ConnectionCallBack = Websocket_ConnectCallback; WSClient.ConnectionCallBack = Websocket_ConnectCallback;
WSClient.DisconnectCallBack = Websocket_DisconnectCallback;
WSClient.ConnectAsync(); WSClient.ConnectAsync();
} }
@@ -431,15 +430,30 @@ namespace PepperDash.Essentials
{ {
StopServerReconnectTimer(); StopServerReconnectTimer();
Debug.Console(1, this, "Websocket connected"); Debug.Console(1, this, "Websocket connected");
WSClient.DisconnectCallBack = Websocket_DisconnectCallback;
WSClient.SendCallBack = Websocket_SendCallback; WSClient.SendCallBack = Websocket_SendCallback;
WSClient.ReceiveCallBack = Websocket_ReceiveCallback; WSClient.ReceiveCallBack = Websocket_ReceiveCallback;
WSClient.ReceiveAsync(); WSClient.ReceiveAsync();
} }
else else
{ {
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failed: {0}", code); if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_HTTP_HANDSHAKE_TOKEN_ERROR)
{
// This is the case when app server is running behind a websever and app server is down
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failed. Check that app server is running behind web server");
}
else if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SOCKET_CONNECTION_FAILED)
{
// this will be the case when webserver is unreachable
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failed");
}
else
{
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failure: {0}", code);
}
StartServerReconnectTimer(); StartServerReconnectTimer();
} }
return 0; return 0;
} }
@@ -670,8 +684,6 @@ namespace PepperDash.Essentials
{ {
if(result != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS) if(result != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "SendCallback questionable result: {0}", result); Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "SendCallback questionable result: {0}", result);
return 0; return 0;
} }