We use Apache Camel as an orchestration mechanism. Typically, the following scenario:
the client sends an HTTP request β CAMEL code β external server (s)
The ball starts to roll when our client sends an HTTP request to our CAMEL code. Camel code will start external servers through REST HTTP calls. In the end, the Camel code will send a response to the client.
The last action before sending a response back to the client, the Camel code sends an HTTP GET to an external server. Thus, a TCP connection is established first, then data is sent. After some time (this may take 5 to 10 seconds), the external server responds with 200 OK.
Problem: Camel does not send TCP FIN to an external server after receiving 200 OK. As a result, the TCP connection remains open ... (the external server then closes the TCP connection after 200 seconds, but this means that the TCP resource has been lost for 200 seconds).
So, at the TCP level, this happens as follows:
Camel <----------> external server
TCP SYN --> <-- TCP SYN,ACK TCP ACK --> HTTP GET --> <-- 200 OK TCP ACK --> <200 seconds later> <-- TCP FIN,ACK TCP ACK -->
Any idea how I can get Camel to close the TCP connection after it got 200 OK?
Note. I tried to add the title βConnection: closeβ, but Camel did not add the title ?! It seemed to ignore it ...
This was the code to add the header:
exchange.getOut().setHeader("Connection","Close");
I am using Camel 2.9.1 in a Spring framework with the Eclipse IDE.