Description
I am using a server behind a NGINX load balancer. My server had an unexpected shutdown and restart. It takes a little time for the server to complete the boot process and during that time NGINX would return an error to anyone who tries to connect to the server.
It seems that if the server fails to reconnect once then it will not try again:
Setup to reproduce:
SocketManager connects initially then upgrades the connection to a websocket
The server on the other side shuts down causing the socket to close and the client code
It takes the server ~30 seconds to come back and be available
Logs:
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketManager: Starting reconnect
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketIOClient{/}: Handling event: statusChange with data: [connecting]
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketIOClient{/}: Handling event: reconnect with data: ["Socket Disconnected"]
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketManager: Trying to reconnect
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketIOClient{/}: Handling event: reconnectAttempt with data: [-1]
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketEngine: Starting engine. Server: wss://dev1.wisdo.com
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketEngine: Handshaking
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketEnginePolling: Doing polling GET https://dev1.wisdo.com/socket.io/?transport=polling&b64=1
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketEnginePolling: Got polling response
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketEnginePolling: Got poll message:
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.8.1</center>
</body>
</html>
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketEngine: Got message:
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.8.1</center>
</body>
</html>
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: ERROR SocketManager: Got unknown error from server
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.8.1</center>
</body>
</html>
Dec 17 10:26:21 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketIOClient{/}: Handling event: error with data: ["Got unknown error from server ...\r\n"]
Dec 17 10:26:31 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketManager: Trying to reconnect
Dec 17 10:26:31 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketIOClient{/}: Handling event: reconnectAttempt with data: [-2]
Dec 17 10:26:31 Gils-MacBook-Pro-4 wisdo[96407]: LOG SocketManager: Tried connecting an already active socket
.... The client now loops but does not try to access the server again..
It will just call connect again and again and again but because status is reconnecting it will just print the warning and do nothing