Anyone know about kotlinx.coroutines.channels.ClosedReceiveChannelException: Channel was closed???

I am receiving back this kotlinx.coroutines.channels.ClosedReceiveChannelException upon about 50% of my api calls to a post url through ktor HttpClient.

Our code looks like

Module.kt

bind<ServiceClient>() with singleton { val client = HttpClient(CIO) { install(JsonFeature) { serializer = KotlinxSerializer() } } ServiceClient( client, instance() ) }

and our implementation of the call is

“` suspend fun post(request: RequestObject): List<ResponseObjects> = client.post(endpoint) { contentType(ContentType.Application.Json) body = request

 } 

“`

Sometimes I am able to receive back the expected results and other times I get the client closed exception. What am I doing wrong here?

I am on ktor version 1.6.4

submitted by /u/cebbbb
[link] [comments]