I am making a web service request that produces a Future. Like so (a simplified reproduction):
import play.api.libs.ws.WSClient
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.duration._
class Service(wsClient: WSClient)(implicit ec: ExecutionContext) {
def callWebService() = {
val req: WSRequest = wsClient.url(...).withRequestTimeout(180 seconds)...
val respFuture:Future[Response] = req.execute()
}
}
The web service being invoked gets 180 seconds to respond before WSClient gives up.
This Service class' client now calls it as service.callWebService()
. When the third party web service takes > 120 seconds, instead of waiting for 180 seconds, the future timesout at 120 seconds (java.util.concurrent.TimeoutException: Read timeout to localhost/127.0.0.1:8081 after 120000 ms
thrown in application-akka.actor.default-dispatcher-3
thread).
Appreciate any pointers on how to increase the 120 seconds used by the default dispatcher to 180 seconds.
Note:
Play WS includes a global request timeout, which defaults to 2 minutes.
Putting the following in your application's config (by default application.conf
) should rectify things.
play.ws.timeout.request = 3 minutes
play.ws.timeout.idle = 3 minutes