Jetty WebSocket TimeOutException:空闲超时到期了吗?

时间:2018-06-08 06:14:09

标签: websocket timeout jetty

我在服务器端的Jetty Websocket(jetty-all-9.4.5.v20170502-uber.jar)上有一次超时:

**java.util.concurrent.TimeoutException: Idle timeout expired: 300011/300000 ms**
Socket Closed: CloseReason[1001,Idle Timeout]
Socket Closed: CloseReason[1001,Idle Timeout]
    at org.eclipse.jetty.io.IdleTimeout.checkIdleTimeout(IdleTimeout.java:166)
    at org.eclipse.jetty.io.IdleTimeout$1.run(IdleTimeout.java:50)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)**

这是一个独特的事件,一切都很完美!

我试图改变这个:

_context = new ServletContextHandler(ServletContextHandler.SESSIONS);
_context.setContextPath("/");
System.out.println(_context.getStopTimeout());
_context.setStopTimeout(0);
_server.setHandler(_context);

〜没有成功!

不知道。

1 个答案:

答案 0 :(得分:1)

  

警告:Don't use jetty-all for your project, its not meant to be used outside of the Jetty Quickstart Documentation.

WebSocket中的空闲超时由WebSocketPolicy控制。

可以在WebSocket容器上指定空闲超时(例如:WebSocketClient或WebSocketServletFactory),甚至可以在各个连接的WebSocket会话上指定。

您的代码示例未显示与WebSocket有关,因此我无法为您提供配置websocket行为所需的特定信息。