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

Vladimir

03/11/2021, 3:09 PM
I recently migrated my app server to ktor + websockets and now we observe those excepeptions in receive loop:
java.util.concurrent.CancellationException: LinkedListChannel was cancelled
(full traceback at https://pastebin.com/GU3a8HMD ) Loop looks like this:
Copy code
try {
            for (frame in websocketSession.incoming) {
                frame as? Frame.Text ?: continue
                val content = frame.readText()

                ctx.sessionScope.launch {
                    handleMessage(ctx, content)
                }
            }
        } catch (e: ClosedReceiveChannelException) {
            // socket is closed from client and handled by ktor
        } catch (e: Throwable) {
            // error occured (abrupt connection termination or other websocket internal error)
            logger.error("Unhandled websocket session error: ${e.message}", e)
        }
Ktor 1.5.2, coroutines 1.4.2, netty 4.1.54.Final
It this proper but not documented cancellation exception or there something fishy is going on?
2 Views