From 5921f49346953731e32200935a1efb7e6b1a3218 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Tue, 24 Sep 2019 11:54:27 +0200 Subject: Catch closed channel exception --- .../src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index 847604fb..7ccd6341 100644 --- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -42,6 +42,7 @@ import io.ktor.websocket.WebSocketServerSession import io.ktor.websocket.webSocket import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.channels.ClosedSendChannelException import kotlinx.coroutines.channels.ReceiveChannel import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.coroutineScope @@ -402,7 +403,10 @@ actual open class KVServiceManager actual constructor(val serviceClass: ) outgoing.send(Frame.Text(text)) } - session.close(CloseReason(CloseReason.Codes.NORMAL, "")) + try { + session.close(CloseReason(CloseReason.Codes.NORMAL, "")) + } catch (e: ClosedSendChannelException) { + } session.close() } launch { -- cgit