I'm calling a webservice using RestEasy Client. One requirement is to abort/timeout the call if it runs for more that 5 seconds. How would I achieve this with RestEasy Client? I have only seen server side timeout, i.e. the Rest Easy websevice will timeout the request if it's not fulfilled within a certain time.
Java – Timeout webservice call from client side
javarestresteasytimeout
Related Topic
- Java – How to get an enum value from a string value in Java
- Bash – Timeout a command in bash without unnecessary delay
- Rest – Understanding REST: Verbs, error codes, and authentication
- Rest – If REST applications are supposed to be stateless, how do you manage sessions
- Json – Posting a File and Associated Data to a RESTful WebService preferably as JSON
- Android error: Failed to install *.apk on device *: timeout
- Rest – Do sessions really violate RESTfulness
- Javascript – How to dispatch a Redux action with a timeout
Best Answer
A RESTEasy client typically uses Apache HttpClient to handle the network conversation.
You can override the HttpClient properties with your own custom timeout parameters:
The first param allows you to specify timeout establishing the initial connection and the second allows you to specify the maximum period of time in which a socket will wait while no data is sent.
You can use the modified HttpClient to build your ClientExecutor:
Which can be used in turn to build a ClientRequest object. Or you can inject it into a RestClientProxyFactoryBean if you are using a Spring configuration for RESTEasy.
It's not exactly the same as an absolute 5 second timeout, but depending on what you are trying to accomplish, tweaking these two properties will usually fill the bill.