I'm trying to get my ktor-client `WebSocketSession...
# ktor
s
I'm trying to get my ktor-client
WebSocketSession
to send a
Close
frame when the program receives a SIGINT, but the session is terminated before I get the chance to send it (which gives me a
ClosedSendChannelException
)! Is there a way around this?
e
Could you provide the example?
s
I'm trying to reproduce it with a basic websocket pointing to
<wss://echo.websocket.org>
, and I got the exception to happen once, but it's happening extremely inconsistently.
Sometimes the socket terminates with an exception, sometimes my code snippet runs on SIGINT as intended, and sometimes the code snippet doesn't run, but doesn't throw an exception either.
In my own project, it happens nearly every time.
I got it. Adding a delay after the close call makes it throw the exception, since it gives the client time to try to send the close call.
https://hastebin.com/uwogomizuz.kt This is a simple demo of the problem