title: Jetty server throws idle timeout for REST calls
body: <p>I have a very simple code snippet to test Jetty server 9.4.41. In the debug level logs I see Timeout Exceptions. I know it is related to idle timeout, and it happens when there is no read/write activity on the connection. But I am just wondering, am I supposed to get the exceptions in the logs? It looks like to me something is not right. I would appreciate if somebody can help to understand why I am getting this.</p>
  <p>Here is my Jetty server code:</p>
  <pre><code>public class JettyServer {
      private Server server;
  
      public void start() throws Exception {
          server = new Server();
          ServerConnector connector = new ServerConnector(server);
          connector.setPort(8090);
          connector.setIdleTimeout(30000);
          server.setConnectors(new Connector[]{connector});
  
          ServletContextHandler handler = new ServletContextHandler(server, &quot;/example&quot;);
          handler.addServlet(ExampleServlet.class, &quot;/&quot;);
  
          server.start();
      }
  }
  </code></pre>
  <p>My Main method just starts this server, and ExampleServlet.class just return a simple success response for the requests: <code>{ &quot;status&quot;: &quot;ok&quot;}</code>. It takes only 50ms to respond (with any REST client, or calling the API using browser).</p>
  <p>Here is the servlet code that generates the response:</p>
  <pre><code>public class ExampleServlet extends HttpServlet {
  
      protected void doGet(
              HttpServletRequest request,
              HttpServletResponse response)
              throws ServletException, IOException {
          response.setContentType(&quot;application/json&quot;);
          response.setStatus(HttpServletResponse.SC_OK);
  
          response.getWriter().println(&quot;{ \&quot;status\&quot;: \&quot;ok\&quot;}&quot;);
      }
  }
  </code></pre>
  <p>Here is the exceptions I see in debug level logs:</p>
  <pre><code>2021-05-30 02:49:42.979:DBUG:oeji.IdleTimeout:Connector-Scheduler-289d1c02-1: SocketChannelEndPoint@976b06a{l=/0:0:0:0:0:0:0:1:8090,r=/0:0:0:0:0:0:0:1:58250,OPEN,fill=FI,flush=-,to=29990/30000}{io=1/1,kio=1,kro=1}-&gt;HttpConnection@45004b9a[p=HttpParser{s=START,0 of -1},g=HttpGenerator@3d68f9d0{s=START}]=&gt;HttpChannelOverHttp@d49259c{s=HttpChannelState@484bba51{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=1,c=false/false,a=IDLE,uri=null,age=0} idle timeout check, elapsed: 29989 ms, remaining: 11 ms
  2021-05-30 02:49:42.995:DBUG:oeji.IdleTimeout:Connector-Scheduler-289d1c02-1: SocketChannelEndPoint@976b06a{l=/0:0:0:0:0:0:0:1:8090,r=/0:0:0:0:0:0:0:1:58250,OPEN,fill=FI,flush=-,to=30005/30000}{io=1/1,kio=1,kro=1}-&gt;HttpConnection@45004b9a[p=HttpParser{s=START,0 of -1},g=HttpGenerator@3d68f9d0{s=START}]=&gt;HttpChannelOverHttp@d49259c{s=HttpChannelState@484bba51{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=1,c=false/false,a=IDLE,uri=null,age=0} idle timeout check, elapsed: 30005 ms, remaining: -5 ms
  2021-05-30 02:49:42.996:DBUG:oeji.IdleTimeout:Connector-Scheduler-289d1c02-1: SocketChannelEndPoint@976b06a{l=/0:0:0:0:0:0:0:1:8090,r=/0:0:0:0:0:0:0:1:58250,OPEN,fill=FI,flush=-,to=30006/30000}{io=1/1,kio=1,kro=1}-&gt;HttpConnection@45004b9a[p=HttpParser{s=START,0 of -1},g=HttpGenerator@3d68f9d0{s=START}]=&gt;HttpChannelOverHttp@d49259c{s=HttpChannelState@484bba51{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=1,c=false/false,a=IDLE,uri=null,age=0} idle timeout expired
  2021-05-30 02:49:42.997:DBUG:oeji.FillInterest:Connector-Scheduler-289d1c02-1: onFail FillInterest@2864451e{AC.ReadCB@45004b9a{HttpConnection@45004b9a::SocketChannelEndPoint@976b06a{l=/0:0:0:0:0:0:0:1:8090,r=/0:0:0:0:0:0:0:1:58250,OPEN,fill=FI,flush=-,to=30007/30000}{io=1/1,kio=1,kro=1}-&gt;HttpConnection@45004b9a[p=HttpParser{s=START,0 of -1},g=HttpGenerator@3d68f9d0{s=START}]=&gt;HttpChannelOverHttp@d49259c{s=HttpChannelState@484bba51{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=1,c=false/false,a=IDLE,uri=null,age=0}}}
  java.util.concurrent.TimeoutException: Idle timeout expired: 30005/30000 ms
      at org.eclipse.jetty.io.IdleTimeout.checkIdleTimeout(IdleTimeout.java:171)
      at org.eclipse.jetty.io.IdleTimeout.idleCheck(IdleTimeout.java:113)
      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      at java.base/java.lang.Thread.run(Thread.java:834)
  2021-05-30 02:49:42.997:DBUG:oejh.HttpParser:Connector-Scheduler-289d1c02-1: close HttpParser{s=START,0 of -1}
  2021-05-30 02:49:42.997:DBUG:oejh.HttpParser:Connector-Scheduler-289d1c02-1: START --&gt; CLOSE
  2021-05-30 02:49:42.997:DBUG:oeji.AbstractConnection:Connector-Scheduler-289d1c02-1: HttpConnection@45004b9a::SocketChannelEndPoint@976b06a{l=/0:0:0:0:0:0:0:1:8090,r=/0:0:0:0:0:0:0:1:58250,OPEN,fill=-,flush=-,to=30008/30000}{io=1/1,kio=1,kro=1}-&gt;HttpConnection@45004b9a[p=HttpParser{s=CLOSE,0 of -1},g=HttpGenerator@3d68f9d0{s=START}]=&gt;HttpChannelOverHttp@d49259c{s=HttpChannelState@484bba51{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=1,c=false/false,a=IDLE,uri=null,age=0} onFillInterestedFailed {}
  java.util.concurrent.TimeoutException: Idle timeout expired: 30005/30000 ms
      at org.eclipse.jetty.io.IdleTimeout.checkIdleTimeout(IdleTimeout.java:171)
      at org.eclipse.jetty.io.IdleTimeout.idleCheck(IdleTimeout.java:113)
      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      at java.base/java.lang.Thread.run(Thread.java:834)
  2021-05-30 02:49:42.998:DBUG:oeji.AbstractEndPoint:Connector-Scheduler-289d1c02-1: shutdownOutput SocketChannelEndPoint@976b06a{l=/0:0:0:0:0:0:0:1:8090,r=/0:0:0:0:0:0:0:1:58250,OPEN,fill=-,flush=-,to=30008/30000}{io=1/1,kio=1,kro=1}-&gt;HttpConnection@45004b9a[p=HttpParser{s=CLOSE,0 of -1},g=HttpGenerator@3d68f9d0{s=START}]=&gt;HttpChannelOverHttp@d49259c{s=HttpChannelState@484bba51{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=1,c=false/false,a=IDLE,uri=null,age=0}
  2021-05-30 02:49:42.999:DBUG:oeji.AbstractConnection:Connector-Scheduler-289d1c02-1: fillInterested HttpConnection@45004b9a::SocketChannelEndPoint@976b06a{l=/0:0:0:0:0:0:0:1:8090,r=/0:0:0:0:0:0:0:1:58250,OSHUT,fill=-,flush=-,to=30009/30000}{io=1/1,kio=1,kro=1}-&gt;HttpConnection@45004b9a[p=HttpParser{s=CLOSE,0 of -1},g=HttpGenerator@3d68f9d0{s=START}]=&gt;HttpChannelOverHttp@d49259c{s=HttpChannelState@484bba51{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=1,c=false/false,a=IDLE,uri=null,age=0}
  2021-05-30 02:49:42.999:DBUG:oeji.FillInterest:Connector-Scheduler-289d1c02-1: interested FillInterest@2864451e{AC.ReadCB@45004b9a{HttpConnection@45004b9a::SocketChannelEndPoint@976b06a{l=/0:0:0:0:0:0:0:1:8090,r=/0:0:0:0:0:0:0:1:58250,OSHUT,fill=FI,flush=-,to=0/30000}{io=1/1,kio=1,kro=1}-&gt;HttpConnection@45004b9a[p=HttpParser{s=CLOSE,0 of -1},g=HttpGenerator@3d68f9d0{s=START}]=&gt;HttpChannelOverHttp@d49259c{s=HttpChannelState@484bba51{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=1,c=false/false,a=IDLE,uri=null,age=0}}}
  2021-05-30 02:49:43.000:DBUG:oeji.ChannelEndPoint:Connector-Scheduler-289d1c02-1: changeInterests p=false 1-&gt;1 for SocketChannelEndPoint@976b06a{l=/0:0:0:0:0:0:0:1:8090,r=/0:0:0:0:0:0:0:1:58250,OSHUT,fill=FI,flush=-,to=0/30000}{io=1/1,kio=1,kro=1}-&gt;HttpConnection@45004b9a[p=HttpParser{s=CLOSE,0 of -1},g=HttpGenerator@3d68f9d0{s=START}]=&gt;HttpChannelOverHttp@d49259c{s=HttpChannelState@484bba51{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=1,c=false/false,a=IDLE,uri=null,age=0}
  2021-05-30 02:49:43.000:DBUG:oeji.ManagedSelector:Connector-Scheduler-289d1c02-1: Queued change lazy=false org.eclipse.jetty.io.ChannelEndPoint$$Lambda$86/0x0000000100123840@6f7f8713 on ManagedSelector@1e730495{STARTED} id=2 keys=1 selected=0 updates=0
  2021-05-30 02:49:43.000:DBUG:oeji.ManagedSelector:Connector-Scheduler-289d1c02-1: Wakeup on submit ManagedSelector@1e730495{STARTED} id=2 keys=1 selected=0 updates=1
  2021-05-30 02:49:43.001:DBUG:oeji.ManagedSelector:qtp157683534-19: Selector sun.nio.ch.WindowsSelectorImpl@1a6c75fe woken with none selected
  2021-05-30 02:49:43.001:DBUG:oeji.WriteFlusher:Connector-Scheduler-289d1c02-1: ignored: WriteFlusher@3f9371c0{IDLE}-&gt;null
  java.util.concurrent.TimeoutException: Idle timeout expired: 30005/30000 ms
      at org.eclipse.jetty.io.IdleTimeout.checkIdleTimeout(IdleTimeout.java:171)
      at org.eclipse.jetty.io.IdleTimeout.idleCheck(IdleTimeout.java:113)
      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      at java.base/java.lang.Thread.run(Thread.java:834)
  2021-05-30 02:49:43.001:DBUG:oeji.ManagedSelector:qtp157683534-19: Selector sun.nio.ch.WindowsSelectorImpl@1a6c75fe woken up from select, 0/0/1 selected
  2021-05-30 02:49:43.001:DBUG:oeji.ManagedSelector:qtp157683534-19: Selector sun.nio.ch.WindowsSelectorImpl@1a6c75fe processing 0 keys, 1 updates
  2021-05-30 02:49:43.001:DBUG:oeji.ManagedSelector:qtp157683534-19: updateable 1
  2021-05-30 02:49:43.002:DBUG:oeji.ManagedSelector:qtp157683534-19: update org.eclipse.jetty.io.ChannelEndPoint$$Lambda$86/0x0000000100123840@6f7f8713
  </code></pre>
  <p>Here is the request and response details:</p>
  <p>Request:</p>
  <pre><code>(GET //localhost:8090/example/)
  Accept */*
  User-Agent PostmanRuntime/7.26.5
  Connection keep-alive
  Postman-Token 83c2a08e-d881-4f94-993d-aa39d3342dd3
  Host localhost:8090
  Accept-Encoding gzip, deflate, br
  Content-Length 1
  Content-Type application/json
  Date: Tue, 01 Jun 2021 15:40:46 GMT
  Content-Type: application/json
  </code></pre>
  <p>Reponse:</p>
  <pre><code>HTTP/1.1 200 
  Date Tue, 01 Jun 2021 15:40:46 GMT
  Content-Type application/json
  </code></pre>