https://kotlinlang.org logo
#ktor
Title
# ktor
e

Evgeny Stroykov

09/20/2023, 5:41 PM
Hello, I am using Ktor client (2.3.2) with CIO engine. There are
maxConnectionsPerRoute
and
maxConnectionsCount
endpoint settings to control how many connections can be made at any moment of time. I am wondering, if there is an easy way to monitor actual number of connections? I want to do that in order to prevent situations where amount of connections reaches a configured maximum. I have a web service that makes HTTP requests while processing an HTTP request from its client, so if it delays too long on acquiring a connection, it affects its own processing of the request. I can see there is a private val
connections
in the
Endpoint
class and looks like this is what I am interested in, but it is private. Am I missing something?
a

Aleksei Tirman [JB]

09/21/2023, 7:50 AM
Unfortunately, there is no easy way to monitor the actual number of the connections because as you correctly noticed the associated variables are private. You can set a connection timeout to prevent a situation where the client waits too long to establish a connection.
e

Evgeny Stroykov

09/21/2023, 9:57 AM
Thanks!!
3 Views