Open Ewg777 opened 2 years ago
Hi, you can use the .ping() method (https://github.com/pusher/NWWebSocket#ping-and-pong) to tell the server that the connection should be maintained. The WebSocketConnectionDelegate protocol has the func webSocketDidReceivePong(connection: WebSocketConnection) so you can handle the pong response from the server. If this fails then you could try reconnecting.
There's also the func webSocketDidDisconnect, where you can try reconnecting here as well: https://github.com/pusher/NWWebSocket#receiving-messages-and-connection-updates
I don't think there's a specific auto-reconnection feature.
I do use the ping method and the connect after webSocketDidDisconnect, but there are many network errors that blocks the next connect. That's why I questioned here @benjamin-tang-pusher
What are the network errors you are receiving? Could you paste them here?
Hey @danielrbrowne! Thanks for a great lib! How to make it always connected to the websocket? Os there any autoreconnection feature?