Mohammed Akram Hussain
08/17/2023, 2:36 PMSerializer for class 'DefaultClientWebSocketSession' is not found
Caused by: kotlinx.serialization.SerializationException: Serializer for class 'DefaultClientWebSocketSession' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
class WebSocketClientImpl(engine: HttpClientEngine) : WebSocketClient() {
private val client = HttpClient(engine) {
install(ContentNegotiation) {
register(
ContentType.Text.Html, KotlinxSerializationConverter(
Json
)
)
}
install(WebSockets) {
contentConverter = KotlinxWebsocketSerializationConverter(Json)
}
}
private var session: WebSocketSession? = null
override fun getWebSocketEvents(): Flow<List<String>> = flow {
session = client.webSocketSession {
url {
takeFrom("<wss://sl-socket-receive.eu.ngrok.io>")
}
}
session!!.incoming
.consumeAsFlow()
.filterIsInstance<Frame.Text>()
//emitAll(data)
}
override suspend fun close() {
session?.close()
session = null
}
}
I have tried multiple things but I'm not able to figure out what's wrong.Aleksei Tirman [JB]
08/17/2023, 2:53 PMregister
call in the ContentNegotiation
plugin, the problem disappears?Mohammed Akram Hussain
08/17/2023, 2:54 PMtext/html
Aleksei Tirman [JB]
08/17/2023, 4:54 PM