'URLSessionWebSocketTask.receive() doesn't throw on cancel()
I am repeatedly calling URLSessionWebSocketTask.receive
. I've tried recursively calling the version with the completion handler, as well as looping over the new async version.
At some point, I'm not receiving any more messages, and I want to cancel the web socket. So I call URLSessionWebSocketTask.cancel()
. In the log, I see the message [websocket] Read completed with an error Operation canceled
. But the completion handler is never called/the async receive method never returns. This means that the Task
I launched to do the receiving never closes.
Why doesn't the completion handler get called when the web socket is cancelled?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|