Replies: 1 comment 1 reply
-
Hi, thanks for reaching out!
When a subscription flow collection ends (either the collecting coroutine is cancelled, or the flow uses some terminal operator like
Yes, this is how it should work already. If you call This error is meant for cases when the server drops the web socket connection without proper STOMP closing handshake. I'm surprised you're facing this in your case. I need to further investigate this exception anyway, to properly define when it should occur and reflect this in the error message. You can track this in #397.
It might be that the server is immediately closing the web socket without closure at STOMP level, but that would be surprising from a Spring server (and I have been using Krossbow with Spring in the past). Also, even if that were the case, Krossbow shouldn't fail with unexpected WS closure if we're calling |
Beta Was this translation helpful? Give feedback.
-
Hello
I am trying to build an Android client for my Springboot backend and one of the features requires Websockets. I implemented Websockets with STOMP and I have run into a small issue. On initial connection, everything is well. The app subscribes to the intended topic and receives the payload. The issue arises when I diconnect. It throws this error:
FATAL EXCEPTION: DefaultDispatcher-worker-2
Process: com.example.zmeasy, PID: 19836
org.hildan.krossbow.stomp.WebSocketClosedUnexpectedly: the WebSocket was closed while subscriptions were still active. Code: 1000 Reason:
at org.hildan.krossbow.stomp.StompSocketKt.decodeToStompEvent(StompSocket.kt:89)
at org.hildan.krossbow.stomp.StompSocketKt.access$decodeToStompEvent(StompSocket.kt:1)
at org.hildan.krossbow.stomp.StompSocket.decodeStomp(StompSocket.kt:38)
at org.hildan.krossbow.stomp.StompSocket.access$decodeStomp(StompSocket.kt:13)
at org.hildan.krossbow.stomp.StompSocket$special$$inlined$map$1$2.emit(Emitters.kt:220)
at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catchImpl$2.emit(Errors.kt:154)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:33)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.access$emitAllImpl$FlowKt__ChannelsKt(Channels.kt:1)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Unknown Source:14)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3b251c1, Dispatchers.IO]
So I was wondering whether Krossbow has some function that can allow me to unsubscribe the user from the topic first before using the disconnect() function. I expected when disconnect() is called, the client would be unsubscribed automatically. Or is this a server issue? Any help would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions