Reputation: 201
I am using play 1.2.5 and in that I am giving async call to REST service.
For that I have created a promise object and then have given this promise object as parameter to await() method. await() method returns me a httpResponse object.
It works fine then the REST service returns a response. But if the REST service do not respond (may be because the REST service is down) then I get a null in the httpResponse. But it takes some time to get the response back.
Can I configure the time it should wait for the rest service to respond for the promise? If not then what is the default wait time?
Any help will be greatly appreciated
Upvotes: 0
Views: 554
Reputation: 26029
There is a timeout call on the WSRequest.
WS.WSRequest wsReq = WS.url("http://whatever");
wsReq.timeout("1min");
...
When you do a postAsync()
, you get a promise back. You can also call promise.onRedeem()
to add a handler to handle errors etc. You could use that to catch the timeout exception.
Upvotes: 0
Reputation: 3833
If you use the play WS lib you have a timeout method on the WSRequest object where you can define the time it takes in seconds before the call returns back if there is no response
Upvotes: 1