How to reconnect a URLSessionWebSocketTask once its cancelled?

898 views Asked by At

I am cancelling or disconnecting an active WebSocket task using the following code

socket.cancel(with: .goingAway, reason: nil)

Is there any way to reconnect back or should we create a new URLSessionWebSocketTask and resume again ?

1

There are 1 answers

0
Miguel Maia On

You should create a new URLSessionWebSocketTask and resume again.