lepicekmichal / SignalRKore

A Kotlin multiplatform coroutine-based SignalR client.
Apache License 2.0
18 stars 3 forks source link

Crash when start a HubConnection #6

Open topanim opened 1 month ago

topanim commented 1 month ago

an incomprehensible conflict, I am inclined to believe that the cause is the dependency versions.

I tried:

What could be the reason?

code:

hubConnection = HubConnectionBuilder.create(
            "wss://domain/path?id=$myId&access_token=$token"
        ) {
            transportEnum = TransportEnum.WebSockets
            httpClient = client
            skipNegotiate = true
            automaticReconnect = AutomaticReconnect.Active
            logger = mylogger
        }

hubConnection.start()

stacktrace:

java.lang.NoClassDefFoundError: Failed resolution of: Lio/ktor/client/plugins/HttpTimeout$HttpTimeoutCapabilityConfiguration;
                    at eu.lepicekmichal.signalrkore.transports.WebSocketTransport$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
                    at io.ktor.client.plugins.HttpTimeoutKt.timeout(HttpTimeout.kt:182)
                    at eu.lepicekmichal.signalrkore.transports.WebSocketTransport.start$lambda$1(WebSocketTransport.kt:44)
                    at eu.lepicekmichal.signalrkore.transports.WebSocketTransport.$r8$lambda$Tn0qvXWIqk7N1IGWOqAvsxXf41Y(Unknown Source:0)
                    at eu.lepicekmichal.signalrkore.transports.WebSocketTransport$$ExternalSyntheticLambda1.invoke(D8$$SyntheticClass:0)
                    at io.ktor.client.plugins.websocket.BuildersKt$webSocketSession$8.invoke(builders.kt:81)
                    at io.ktor.client.plugins.websocket.BuildersKt$webSocketSession$8.invoke(builders.kt:79)
                    at io.ktor.client.plugins.websocket.BuildersKt.webSocketSession(builders.kt:36)
                    at io.ktor.client.plugins.websocket.BuildersKt.webSocketSession(builders.kt:79)
                    at eu.lepicekmichal.signalrkore.transports.WebSocketTransport.start(WebSocketTransport.kt:41)
                    at eu.lepicekmichal.signalrkore.HubConnection.start(HubConnection.kt:156)
                    at eu.lepicekmichal.signalrkore.HubConnection.start$default(HubConnection.kt:121)
                    at io.eduonline.devrush.devrushlmsmultiplatform.domain.network.devrushApi.modules.chat.ChatModule.init(ChatModule.kt:60)
                    at io.eduonline.devrush.devrushlmsmultiplatform.features.chat.presentation.ChatViewModel$initChat$1.invokeSuspend(ChatViewModel.kt:53)
                    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
                    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
                    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:96)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:816)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
                    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)
                    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@4d9ae61, Dispatchers.IO]
topanim commented 1 month ago

my client:

HttpClient(get()) {
            install(WebSockets)
            install(HttpTimeout) {
                socketTimeoutMillis = 30_000
                connectTimeoutMillis = 30_000
                requestTimeoutMillis = 30_000
            }
            install(ContentNegotiation) { json(get()) }
            followRedirects = false
        }

ktor version: 3.0.0-wasm2

lepicekmichal commented 1 month ago

Yeah, I have not tried ktor version 3 yet nor do I specify support for web assembly. I will look into it though, probably this sunday or following week.

topanim commented 1 month ago

Thanks for the reply.

I don't have to use version 3.x.x, but lowering the version didn't help either. What can be done to make the project work?

lepicekmichal commented 1 month ago

Okay, I can't see the problem then. Could you share a demo project producing this error?