Play framework Idle Connection Timeout Exception

本文介绍了解决 Playframework 中 WS 客户端调用远程服务时遇到的超时问题。通过调整应用配置文件 application.conf 中的 ws.timeout.idle 参数,可以有效延长空闲连接超时时间,解决因响应时间过长导致的 TimeoutException 异常。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Play framework version: 2.3.x

Problem:

Application A is using WS.url to call an endpoint in Application B. The endpoint in Application B took more than 2 mins to respond.

And we got the exception like this:

java.util.concurrent.TimeoutException: Idle connection timeout to ip-xxxxxxxx/127.0.0.1:9000 of 120000 ms

Resolution:

add this line in application.conf

ws.timeout.idle=600000

the unit above is ms so that the idle connection timeout is enlarged.

One way to test if this setting is working is:

Set this timeout to a small value like 6000, and add a Thread.sleep(7000) in the endpoint of Application B

You can get the above exception after 6 seconds when the endpoint of Application B is called.

Please be noted that Idle connection timeout is different with a http timeout. So only by setting WS.url(someUrl).setTimeout(60 * 1000) is useless.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值