https://kotlinlang.org logo
#ktor
Title
# ktor
s

serebit

03/09/2019, 10:00 PM
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

e5l

03/11/2019, 12:46 PM
Could you provide the example?
s

serebit

03/12/2019, 1:52 AM
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
3 Views