hello. i am trying to use the ktor lib in order to perform some cloud requests. if i have a vpn connection ON on the device, the requests get timeout (even if the timeout is set to 30 seconds). i will leave in the thread how chatGPT suggested to configure the HttpClient I use in order to avoid the problem, but I still encounter it
has anyone encountered this issue?
Vlad Ghilicica
11/03/2025, 4:02 PM
Copy code
HttpClient(OkHttp) {
engine {
config {
// Use system DNS resolver instead of OkHttp's cached DNS
dns { hostname -> InetAddress.getAllByName(hostname).toList() }
// Reduce connection pool keep-alive time to handle VPN switches better
connectionPool(
ConnectionPool(
maxIdleConnections = 5,
keepAliveDuration = 30,
timeUnit = TimeUnit.SECONDS
)
)
// Force connection retry on connection failure
retryOnConnectionFailure(true)
}
}
}
c
Chrimaeon
11/03/2025, 7:27 PM
Please don’t cross post to multiple channels. Use the most suitable one and delete the other posts. It’s hard to follow the conversation for others if you have multiple posts.
v
Vlad Ghilicica
11/04/2025, 8:07 AM
hello. ok, thank you. in your opinion, which is the most suitable channel for this question: #C0B8M7BUY ori #C3PQML5NU?