[android] Failed to connect at STOMP protocol level to host
See original GitHub issue**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
Issue Analytics
- State:
- Created a year ago
- Comments:18 (10 by maintainers)
Top Results From Across the Web
Set up a Stomp client in android with Spring framework ...
To obtain a more dynamic android application, i am trying to use WebSocket protocol with Stomp messages. After some research, i found that...
Read more >STOMP Compatibility · Issue #5 · Tinder/Scarlet
I tried and failed to implement a STOMP connection because of a lack of documentation. Please add a working example and not just...
Read more >IPWorks MQ 2020 Android Edition Reference
Connecting to a STOMP server is easy; in the simplest case just call the Connect method, passing the server's hostname and port number....
Read more >WebSocket Implementation with Spring Boot and STOMP
In this article, I am going to show you how to implement WebSockets with the Spring Boot Framework. I will cover both the...
Read more >Using WebSocket to build an interactive web application
In this guide, we use STOMP messaging with Spring to create an interactive web application. STOMP is a subprotocol operating on top of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.