这是我们的Jetty 9.2.3服务器配置,后面是我最终得到的服务器上的“java.util.concurrent.TimeoutException”堆栈跟踪。
场景:在我们的开发环境中,我一直向Jetty服务器发送25个并发请求,并且我立即得到一些请求的“java.util.concurrent.TimeoutException”异常,而不是全部。
例外:下面粘贴了完整的堆栈跟踪。在http请求主体中读取部分json请求之后发生异常,然后其余的json请求未通过http请求的输入流,从而导致IO块在空闲时间内踢出毫秒并超时。
我在哪里错误导致超时?请指教。谢谢。
服务器配置:
//new ExecutorThreadPool(corePoolSize, maxPoolSize, keepAliveTimeout, TimeUnit.SECONDS)
Server server = new Server(new ExecutorThreadPool(25, 50, 30, TimeUnit.SECONDS));
HttpConfiguration configuration = new HttpConfiguration();
configuration.setRequestHeaderSize(8192);
LowResourceMonitor lowResourceMonitor = new LowResourceMonitor(server);
lowResourceMonitor.setLowResourcesIdleTimeout(150);
lowResourceMonitor.setMaxConnections(700);
server.addBean(lowResourceMonitor);
ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(configuration));
connector.setHost(host);
connector.setPort(port);
connector.setIdleTimeout(300);
connector.setAcceptQueueSize(256);
connector.setReuseAddress(true);
connector.accept(1);
server.setConnectors(new Connector[] { connector });
例外:
2014-11-02 20:17:36,481 [ERROR] [pool-39-thread-13] c.t.gth.e.DE - Error trying to get: java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 200/200 ms
java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 200/200 ms
at org.eclipse.jetty.util.SharedBlockingCallback$Blocker.block(SharedBlockingCallback.java:234) ~[jetty- util-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.HttpInputOverHTTP.blockForContent(HttpInputOverHTTP.java:66) ~[jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.HttpInput$1.waitForContent(HttpInput.java:456) ~[jetty- server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.HttpInput.read(HttpInput.java:121) ~[jetty-server- 9.2.3.v20140905.jar:9.2.3.v20140905]
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283) ~[na:1.7.0_51]
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325) ~[na:1.7.0_51]
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177) ~[na:1.7.0_51]
at java.io.InputStreamReader.read(InputStreamReader.java:184) ~[na:1.7.0_51]
at java.io.Reader.read(Reader.java:140) ~[na:1.7.0_51]
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2001) ~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1980) ~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1957) ~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1907) ~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.toString(IOUtils.java:778) ~[commons-io-2.4.jar:2.4]
at org.apache.commons.io.IOUtils.toString(IOUtils.java:803) ~[commons-io-2.4.jar:2.4]
at com.xyz.gth.adapter.MOP.convertStreamToString(MOP.java:729) ~[bdd-1.19.18.3.3.1.jar:1.19.18.3.3.1]
at com.xyz.gth.adapter.MOP.handleRequest(MOP.java:129) ~[bdd-1.19.18.3.3.1.jar:1.19.18.3.3.1]
at com.xyz.gth.adapter.MoPubFilterAdapter.handleRequest(MoPubFilterAdapter.java:65) ~[bdd-1.19.18.3.3.1.jar:1.19.18.3.3.1]
at com.xyz.gth.e.ED.getTBR(ED.java:1600) [bdd-1.19.18.3.3.1.jar:1.19.18.3.3.1]
at com.xyz.gth.e.ED.process(ED.java:613) [bdd-1.19.18.3.3.1.jar:1.19.18.3.3.1]
at com.xyz.gth.eHandler.handle(eHandler.java:122) [bdd-1.19.18.3.3.1.jar:1.19.18.3.3.1]
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.Server.handle(Server.java:497) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248) [jetty-server-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [jetty-io-9.2.3.v20140905.jar:9.2.3.v20140905]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51]
Caused by: java.util.concurrent.TimeoutException: Idle timeout expired: 200/200 ms
at org.eclipse.jetty.io.IdleTimeout.checkIdleTimeout(IdleTimeout.java:156) ~[jetty-io-9.2.3.v20140905.jar:9.2.3.v20140905]
at org.eclipse.jetty.io.IdleTimeout$1.run(IdleTimeout.java:50) ~[jetty-io-9.2.3.v20140905.jar:9.2.3.v20140905]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) ~[na:1.7.0_51]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) ~[na:1.7.0_51]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) ~[na:1.7.0_51]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) ~[na:1.7.0_51]
... 3 common frames omitted