I have a question about websockets, i have a Chann...
# ktor
j
I have a question about websockets, i have a Channel that i am calling consumeEach on in the body of the webSocket route. This channel opens some resources which i would like to close if the websocket receives a client disconnect. Anyone any suggestions on how i might go about that?
t
This is what I’m doing. The finally should get called when the socket disconnects.
j
Thanks for that, but i think the reason this works is you are trying to receive messages, meaning if the client closes the socket you get an exception thrown at that point.
t
Right and you’re looking for a solution that isn’t exception based?
j
I dont mind if its exception based, but i am not expecting to receive anything from the client so im not calling receiveMessage
w
isn't the exception still thrown in that case?
j
well from my testing the websocket block is suspended waiting on the channel and no exception is thrown