I am using apache-camel as client for http and https requests.
After requests are processed the connections are going into CLOSE_WAIT
.
My camel-context doesn't stop after the execution of requests.
If I stop it manually then connections are going into TIME_WAIT
.
Now I am wondering if I can make connections to go into TIME_WAIT
by some configuration in camel-context or code for http requests.
Edited:
I have tried solutions mentioned for this issue like adding
"Connection"
header with value"close"
. But it didn't work.I have used
HttpComponent
like below to close connections infinally
block
Code:
HttpComponent httpComponent = (HttpComponent) pContext.getComponent(ServerConstants.CAMEL_COMPONENT_HTTP);
httpComponent.getHttpConnectionManager().closeIdleConnections(0);
Second solution is working for http
connections but not for https
.
Solution:
Finally able to make it work by defining custom HeaderFilterStrategy
which does not filter Connection
:close
header and setting this filter bean id in URL
as query param.