Michael
Michael

Reputation: 10303

How to make Apache Http client resume waiting for response after timeout?

I use executeMethod of Apache Http client, which blocks until it receives the server response. I can set the timeout but it looks like that the client cannot resume waiting for response once the timeout is expired.

Can I make Apache Http client resume waiting for response after the timeout ?

Upvotes: 2

Views: 1598

Answers (3)

Partha
Partha

Reputation: 570

Create a separate thread and block on execute method. When it times out repeat the process once again.

Upvotes: 1

Yuval Rimar
Yuval Rimar

Reputation: 1055

I think that the timeout you set is actually the socket timeout, so when it expires the socket closes and you need to repeat the executeMethod call.

Upvotes: 1

Alex Gitelman
Alex Gitelman

Reputation: 24732

Timeout means that for purposes of your application, you are done waiting for response. If you intend to continue waiting and just want to do something every once in a while, I'd suggest you use separate thread for Http connection. Then you can do what you need while continue waiting. And you should be able to kill the connection if you decide to stop waiting.

Upvotes: 1

Related Questions