Understanding "The target server failed to respond" in Nexus logs

Summary

You are noticing messages like this in your Nexus log:

2014-08-05 07:19:42 INFO [qtp2021455193-55711] anonymous org.sonatype.nexus.apachehttpclient.Hc4ProviderBase$DefaultHttpClientImpl - I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond

2014-08-05 07:19:42 INFO [qtp2021455193-55711] anonymous org.sonatype.nexus.apachehttpclient.Hc4ProviderBase$DefaultHttpClientImpl - Retrying request

Explanation

The root cause of these messages are as discussed in NEXUS-5368.

Idle socket connections established with remotes are expiring on the remote server, but they are still 'open' as far as Nexus is concerned.

Upon pulling a cached idle connection from the connection pool, a socket check is performed by the Nexus HTTP Client. If the socket is now closed, you will see a message that the socket is immediately closed and the connection is retried. For example:

2014-08-06 09:32:29 DEBUG [qtp2021455193-70353] anonymous org.apache.http.impl.conn.DefaultClientConnection - Connection 0.0.0.0:53668<->216.34.181.96:80 closed 
2014-08-06 09:32:29 INFO [qtp2021455193-70353] anonymous org.sonatype.nexus.apachehttpclient.Hc4ProviderBase$DefaultHttpClientImpl - I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
2014-08-06 09:32:29 INFO [qtp2021455193-70353] anonymous org.sonatype.nexus.apachehttpclient.Hc4ProviderBase$DefaultHttpClientImpl - Retrying request
2014-08-06 09:32:29 DEBUG [qtp2021455193-70353] anonymous org.apache.http.impl.conn.DefaultClientConnectionOperator - Connecting to logicaldoc.sourceforge.net:80

Upon the first retry by the same thread of this initial failure ( by default there are 3 retries ), a new socket connection is opened, and the request usually succeeds.

A good command to grep for these from the nexus log file is the following:

pcregrep -A 1 -B 2 -M 'Retrying request' nexus.log 

Basically, this behaviour is normal and there is nothing that can be done in Nexus 100% reliably here.

Ideally the remote hosts should reply with a Keep-Alive header which states how long the connection will be kept open on the remote. For example:

Keep-Alive: timeout=10, max=127

The above header would tell nexus to treat the idle connection as expired on the remote automatically after 10 seconds.

By default, Nexus will keep idle connections around for up to 30 seconds before evicting them from the pool. This is controlled by this property:

https://github.com/sonatype/nexus-oss/blob/nexus-2.8.x/components/nexus-core/src/main/java/org/sonatype/nexus/apachehttpclient/Hc4ProviderImpl.java#L85-85

Every 5 seconds , Nexus checks the pool for idle connections which have exceeded their idle time out. Theseidle connections are evicted from the pool automatically.

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk