[2.1.3-Java] How to increase Request Timeout in Play 2.1.3

2,077 views
Skip to first unread message

Nishanth Chakrapani

unread,
Jun 17, 2014, 2:05:40 PM6/17/14
to play-fr...@googlegroups.com
Hello Team,
    I am calling a web service which is hosted in the same system and that web service calls another web server in the internet and returns huge data. The web service takes more than 3 minutes to return data. But i keep getting below error in play controller. How can i increase the request timeout while calling a web service from Play. 

I had already tried setting the ws.timeout=1200000 value and it did not work. Please help me on the same. 

Below is code block: 
Promise<Response> lSubmitServiceRes = WS.url(RestHelper.buildURI("url")))
     .setHeader(Messages.get("response.accept"),"application/json").get();
     .setTimeout(1200000).get();
     Response response = lSubmitServiceRes.get(new Long(1200000));//Set timeout for 20 mins

Below is the error i am getting every time regardless of the timeout i set:
java.util.concurrent.TimeoutException: Idle connection timeout of 60000 ms
        at com.ning.http.client.providers.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
        at com.ning.http.client.providers.netty.timeout.IdleConnectionTimeoutTimerTask.run(IdleConnectionTimeoutTimerTask.java:53)
        at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:546)
        at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:446)
        at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:395)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        at java.lang.Thread.run(Thread.java:744)


Megazord

unread,
Jun 18, 2014, 2:27:19 PM6/18/14
to play-fr...@googlegroups.com
I guess that you are setting timeout for the future instead of the http request. Try to set the timeout **before** doing the get:

long timeout = 1200000;

Promise<Response> promiseGet = WS.url(RestHelper.buildURI("url")))
                                 .setTimeout(timeout)
                                 .setHeader(Messages.get("response.accept"),"application/json")
                                 .get();

Response response = promiseGet.get(timeout);


HTH

Nishanth Chakrapani

unread,
Jun 18, 2014, 3:30:37 PM6/18/14
to play-fr...@googlegroups.com
Hello Magazord,
     I did try the below code, but its not working. I still get the same error regardless of specifying the timeout. Please let me know if anything else can be done.
Regards,
Nishanth.

Megazord

unread,
Jun 18, 2014, 3:47:17 PM6/18/14
to play-fr...@googlegroups.com
Looks like play is setting the timeout properly:

https://github.com/playframework/playframework/blob/2.1.x/framework/src/play-java/src/main/java/play/libs/WS.java#L446-L461

I suggest that you investigate async-http-client issues to see if there is something related to timeouts:

https://github.com/AsyncHttpClient/async-http-client/search?q=timeout&type=Issues

HTH

Nishanth Chakrapani

unread,
Jun 18, 2014, 4:25:41 PM6/18/14
to play-fr...@googlegroups.com
Hello Megazord,
   Thanks for the answer. I googled it a bit and found this stackoverflow question. They say its a issue with play. Can you please check this. 

Megazord

unread,
Jun 18, 2014, 5:34:07 PM6/18/14
to play-fr...@googlegroups.com
Well, looks like you will need to upgrade to a newer version of Play, probably 2.2+.

Best,
Reply all
Reply to author
Forward
0 new messages