krossbow: [android] Failed to connect at STOMP protocol level to host
**When trying to connect on android ** My Code :
lifecycleScope.launch {
val client = StompClient(OkHttpWebSocketClient())
try {
val session =
client.connect(
host = "/",
url = BuildConfig.SOCKET_STOMP,
customStompConnectHeaders = mapOf("Authorization" to "Bearer ${preferences.currentUser?.authToken}"),
sessionCoroutineContext = Dispatchers.Default
)
session.use {
val subscription: Flow<String> =
it.subscribeText("${Constants.CHATS.SUBSCRIPE_CHAT}${channelId}")
val firstMessage: String = subscription.first()
//getMessage(firstMessage)
Log.d("ChatsViewModel", "openConnectionWithChat:${firstMessage} ")
val gson = Gson()
val json = gson.toJson(bodyText())
it.sendText(
"${Constants.CHATS.DESTINATION_CHAT}${channelId}",
json.toString()
)
}
} catch (ex: Exception) {
ex.printStackTrace()
}
}
The Error Is :
2022-10-22 18:35:56.089 10151-10151/com.docformative.docformative W/System.err: org.hildan.krossbow.stomp.StompConnectionException: Failed to connect at STOMP protocol level to host '/'
2022-10-22 18:35:56.090 10151-10151/com.docformative.docformative W/System.err: at org.hildan.krossbow.stomp.StompWsExtensionsKt.stomp(StompWsExtensions.kt:36)
2022-10-22 18:35:56.090 10151-10151/com.docformative.docformative W/System.err: at org.hildan.krossbow.stomp.StompWsExtensionsKt$stomp$1.invokeSuspend(Unknown Source:13)
2022-10-22 18:35:56.090 10151-10151/com.docformative.docformative W/System.err: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2022-10-22 18:35:56.090 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
2022-10-22 18:35:56.090 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
2022-10-22 18:35:56.090 10151-10151/com.docformative.docformative W/System.err: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
2022-10-22 18:35:56.090 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:367)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith$default(DispatchedContinuation.kt:278)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.internal.ScopeCoroutine.afterCompletion(Scopes.kt:28)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.JobSupport.continueCompleting(JobSupport.kt:936)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.JobSupport.access$continueCompleting(JobSupport.kt:27)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.JobSupport$ChildCompletion.invoke(JobSupport.kt:1155)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1520)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:323)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:240)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:906)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:863)
2022-10-22 18:35:56.091 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:828)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at android.os.Handler.handleCallback(Handler.java:938)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at android.os.Looper.loopOnce(Looper.java:210)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at android.os.Looper.loop(Looper.java:299)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at android.app.ActivityThread.main(ActivityThread.java:8293)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
2022-10-22 18:35:56.092 10151-10151/com.docformative.docformative W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
2022-10-22 18:35:56.093 10151-10151/com.docformative.docformative W/System.err: Caused by: java.lang.IllegalStateException: Expected CONNECTED frame in response to CONNECT, got org.hildan.krossbow.stomp.frame.StompEvent$HeartBeat@b9a59a
2022-10-22 18:35:56.093 10151-10151/com.docformative.docformative W/System.err: at org.hildan.krossbow.stomp.StompWsExtensionsKt.awaitConnectedFrame(StompWsExtensions.kt:58)
2022-10-22 18:35:56.093 10151-10151/com.docformative.docformative W/System.err: at org.hildan.krossbow.stomp.StompWsExtensionsKt.access$awaitConnectedFrame(StompWsExtensions.kt:1)
2022-10-22 18:35:56.093 10151-10151/com.docformative.docformative W/System.err: at org.hildan.krossbow.stomp.StompWsExtensionsKt$awaitConnectedFrame$1.invokeSuspend(Unknown Source:13)
2022-10-22 18:35:56.093 10151-10151/com.docformative.docformative W/System.err: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2022-10-22 18:35:56.093 10151-10151/com.docformative.docformative W/System.err: ... 9 more
- krossbow-stomp-core:4.2.0 : 4.2.0
- krossbow-websocket-okhttp :4.2.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (11 by maintainers)
@EslamMohamed3396 did you have any news on this?
@EslamMohamed3396 did you get the chance to understand how you’re getting heartbeats there from a previous connection?
I was thinking that even if I add a feature/config to ignore such heartbeats during the handshake, if those heartbeats continue afterwards they might not match the expectations of a potential new heartbeat negotiation result (from the new connection). So depending on why you get them, it’s likely still going to be a problem.
I will try now to force cancel and ping you
Thanks for the extra information. I’ll make the connection resistant to weird heart beats, but it might not fix your root issue.
Maybe the initial connection/session is not closed (despite the
usemaybe your coroutine is not cancelled and thus the session not closed). The could explain why some heartbeat is received during the next handshake.By the way, do you control the server? Do you see any suspicious logs there?
Hi, thanks a lot for the report! At first glance, 2 things catch my attention:
hostis set to/in theclient.connect(...)call, why is that?/is not a valid host, so this seems strange. Is there a specific reason you’re overriding it instead of letting the default be the URL’s host?CONNECT/CONNECTEDframes pair. I wonder if something is going on with the server. Could you please share a bit of context with this? Does it happen in particular circumstances? Do you have any errors on the server side by the way?