-
Type: Bug
-
Status: Resolved
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 5.6
-
Fix Version/s: 5.6.0-HF13, 5.7.1
-
Component/s: None
-
Tags:
We may be leaving connections around: many connections staying in CLOSE_WAIT state, when seen with netstat.
Audit our code to be sure.
Apache HttpClient holds TCP connections, but they are usually not released automatically when the client object is forgotten at the end of a method, even though the HttpMethod (either PostMethod, PutMethod, GetMethod, ...) has fully consumed its result. Even calling httpMethod.releaseConnection() is not enough as it may just release the connection to the pool and not close it.
To fix this, there are several possibilities:
- call addHeader("Connection", "close"); on the HttpMethod to make it be used only once then closed,
- call ConnectionManager.closeIdleConnections when done,
- have proper reuse of the HttpClient objects during the lifetime of the server.
The first two don't make use of any pooling so are a bit more inefficient, but it's better than leaving connections around anyway.
- is required by
-
NXP-11258 Review HttpClient usage to avoid CLOSE_WAIT TCP sockets
- Open