How to reconnect a URLSessionWebSocketTask once its cancelled?

912 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 best solutions below

0
On

You should create a new URLSessionWebSocketTask and resume again.