-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to make socket is always connected? #32
Comments
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?
The text was updated successfully, but these errors were encountered: