HTTP client-server, I don't think i'm closing my client side connections with BasicResponseHandler()

StackOverflow https://stackoverflow.com/questions/7870643

  •  11-02-2021
  •  | 
  •  

Question

I have a server implemented using Apache HTTPCore which can accept posts from an httpclient implementation. I have enough of it working so that I can send to the server, processes the post contents, and get the response back on the client. Everything seems to work, however I am noticing that the server keeps the connection alive until it times out, even though the client connection has completed successfully. I'm assuming that I need to close the connection on the client side after receiving the response, however I believe I am already doing that as I am using BasicResponseHandler(), which returns a String, so I can't figure out what if anything I need to actually close.

Any thoughts on this? I was going to try using a different response handler that returns an InputStream, and see if closing that works, but I assumed that BasicResponseHandlerwas doing that behind the scenes already as it returns a String

Was it helpful?

Solution

If the server hasn't read an EOS, the client hasn't closed the connection. Having a read timeout on the connection to the client is the correct strategy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top