Ktor: call.receiveText() timeout

I’ve recently developed a simple Ktor app and organized a hosting for it on Apache Webserver + Tomcat.

The app has post { … } route used for processing HTTP POST requests. The route works fine for all requests except the first one.

Some additional tracing shows that request processing stucks on the line

call.receiveText()

where I read the POST JSON body for further parsing. The request is stuck until network timeout, and I couldn’t detect the actual processing time (it takes minutes).

Every following POST request with exactly the same content is processed fine. In Tomcat settings I put “load-on-startup” - it didn’t affect the result.

What could be the reason of such behavior? I assume some lazy loading issue. Does Ktor provide some mechanism to force initialization of the library components?