Enabling stale check will consume an additional 15 milliseconds for each HTTP request. The stalecheck option is enabled by default.
Is this necessary ????
When a web API service is called in the LAN, it will become dead.
Http://stackoverflow.com/questions/11219325/why-does-defaulthttpclient-send-data-over-a-half-closed-socket
Http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html
Http://www.mail-archive.com/httpclient-users@hc.apache.org/msg02710.html
I checked some information and found that stalecheck should be disabled for performance.
Someone suggested that the Java httpclient should add an idle Monitor thread in the connection pool to remove the Broken connection. Otherwise, the stale connection of re-use may be disconnected by the server, which may cause an exception.
However, because Java's traditional communication method is blocking, The Global idle Monitor thread cannot be universal. To support a large number of connections, configuring a Monitor thread for each connection is not feasible.
Therefore, the official Apache httpclient documentation is recommended as follows:
Clientconnectionmanager # closeexpiredconnections ()
Clientconnectionmanager # closeidleconnections ()
The caller needs to call one of the above two methods on a regular basis to reduce broken stale connections
At the same time, the caller needs to decide whether to retry the IO exception.