1 year ago

#295560

test-img

Ant

Root cause of java.net.ConnectException / java.net.SocketException

We’re using an apache CachingHttpClient with a PoolingHttpClientConnectionManager configured and all accessed via a Spring RestTemplate.

Most of our connectivity is from Azure -> on-prem service using the same url. Under production load we get occasional exceptions above showing “Connection timed out: connect” or “connect timed out”, they both share the same root cause:

Java.net.PlainSocketImpl.waitForConnect

We’ve had a few stabs at configuring the PoolingHttpClientConnectionManager with maxConnections/maxConnectionsPerRoute. From default 20/2 -> 40/8

This has improved our application throughput but still some connections timeout.

What I’m struggling with is knowing whether waitForConnect means the 40/8 config is throttling our application and connections are waiting for free routes OR the pooled connection / route is free but there is network latency preventing the connection from being made.

I hope that makes sense. I have debug logging on the apache classes but it’s still not clear to me.

java

apache-httpclient-4.x

0 Answers

Your Answer

Accepted video resources