pusher / pusher-websocket-swift

Pusher Channels websocket library for Swift
https://pusher.com/channels
MIT License
273 stars 166 forks source link

Fix reconnection issue #413

Closed alvaro-delacruz-bat closed 1 year ago

alvaro-delacruz-bat commented 1 year ago

Description of the pull request

The modification aims to reestablish the connection whenever the WebSocketConnectionDelegate triggers the webSocketDidReceiveError event due to any POSIX error, except for ENOTCONN (code 57 - Socket is not connected).

Why is the change necessary?

After thorough monitoring, we observed that whenever the WebSocketConnectionDelegate triggers the webSocketDidReceiveError event due to any POSIX error other than ENOTCONN, the socket loses its connection. However, the WebSocketConnectionDelegate fails to call the webSocketDidDisconnect method, leaving the instance in a "connected" state, even though it is effectively disconnected. This situation prevents reconnection attempts, forcing users to restart the app to establish a new connection.