socket.io-client-swift
socket.io-client-swift copied to clipboard
Handling reconnect scenarios properly when socket is hung
In situations where the socket connection is lost via a SO_ERROR, even though reconnect is enabled, the socket manager hangs the socket until a manual disconnect. Symptom would be: the app would output something like the following:
2019-01-09 12:15:49.005630+0000 App [13746:3543026] [] nw_socket_handle_socket_event [C10.1:1] Socket SO_ERROR [61: Connection refused]
2019-01-09 12:15:49.016640+0000 App [13746:3543026] [] nw_socket_handle_socket_event [C10.2:1] Socket SO_ERROR [61: Connection refused]
Socket-IO would be logging the retry requests over and over again with the following log:
Tried connecting an already active socket
In this case, the active socket is hung, so a retry would never be attempted. This condition can be simulated by running an app on a simulator while turning on Network Link Conditioner with 100% packet loss profile.
This fix simply recycles the engine in the case that a connecting status has 1 or more retry attempts. This seems to resolve the issue.