I'm getting a really strange exception using ktor-...
# ktor
d
I'm getting a really strange exception using ktor-client
3.2.3
with SSE.
Copy code
Caused by: kotlinx.serialization.SerializationException: Serializer for class 'ClientSSESession' is not found.
For some reason, the
private suspend inline fun <reified T> HttpClient.processSession
method is trying to create a body of type
ClientSSESession
, which seems wrong to me, but i don't really know.
Copy code
statement.body<T, Unit> { session ->
    sessionDeferred.complete(session)
}
My HttpClient configuration is:
Copy code
defaultRequest {
            url(baseUrl)
            bearerAuth(apiKey)
            contentType(ContentType.Application.Json)
        }

        install(ContentNegotiation) {
            json(json)
        }

        install(SSE) {
Okay, I found a solution (kind of). I had a mistake in my request (method needed to be set to post). So the server responded with
400 Bad Request
. For some reason, that caused ktor client to try to deserialize the response body as the ClientSSESession, which is not the correct behavior IMO. I don't see any obvious place to intercept response failures before the SSE kicks in.
a
Can you please share a complete code snippet to reproduce the problem?
d
I'll see if I can create a unit test that does...
Here is a unit test that shows the issue.
a
Thank you for the code snippet. I've added your test to the respective issue.
👍 1