title: Tomcat EOFException: Unexpected EOF read on the socket
body: <p>I want to better understand how Tomcat handles requests and why my specific issue may be happening.</p>
  
  <p>I am trying to enhance my existing Spring MVC web application with the Netflix Hystrix framework. This involves adding a hystrix-specific servlet to handle requests ending with /hystrix.stream. </p>
  
  <p>Based on the logs (below), this mapping works and the request is being forwarded to the correct servlet. However, the exception that is thrown does not occure in the servlet. I have also tried extending the servlet to add additional logging - but it appears that no methods in the servlet are called. The exception seems to be happening because of some inner working on Tomcat that I am not aware of.</p>
  
  <p>Here is a snippet from my web.xml (note that the rest of my application works fine - this is just concerning requests for /hystrix.stream):</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;display-name&gt;HystrixMetricsStreamServlet&lt;/display-name&gt;
      &lt;servlet-name&gt;HystrixMetricsStreamServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;HystrixMetricsStreamServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/hystrix.stream&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>When I navigate to loalhost:8080/web-app/hystrix.stream I am forwarded to the Tomcat 404 Error. The following exception appears in tomcat's log file:</p>
  
  <pre><code>2014-04-16 15:53:22 DEBUG AuthenticatorBase:419 - Security checking request GET /web-app/hystrix.stream
  2014-04-16 15:53:22 DEBUG WebappClassLoader:1582 - loadClass(com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet, false)
  2014-04-16 15:53:22 DEBUG WebappClassLoader:1598 -   Returning class from cache
  2014-04-16 15:53:22 DEBUG RealmBase:617 -   No applicable constraints defined
  2014-04-16 15:53:22 DEBUG AuthenticatorBase:501 -  Not subject to any constraint
  2014-04-16 15:53:22 DEBUG [localhost]:449 - Processing ErrorPage[errorCode=404, location=/404.htm]
  2014-04-16 15:53:22 DEBUG Http11Processor:986 - Error parsing HTTP request header
  java.io.EOFException: Unexpected EOF read on the socket
              at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:99)
              at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:952)
              at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
              at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
              at java.lang.Thread.run(Unknown Source)
  
  2014-04-16 15:53:22 DEBUG Http11Protocol:645 - Socket: [org.apache.tomcat.util.net.SocketWrapper@56a7cbf2:129bf96a[TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: Socket[addr=/0:0:0:0:0:0:0:1,port=53783,localport=8443]]], Status in: [OPEN_READ], State out: [CLOSED]
  2014-04-16 15:53:22 DEBUG LimitLatch:126 - Counting down[http-bio-8443-exec-1] latch=4
  2014-04-16 15:53:22 DEBUG Http11Processor:986 - Error parsing HTTP request header
  java.io.EOFException: Unexpected EOF read on the socket
              at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:99)
              at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:952)
              at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
              at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
              at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Has anyone encountered something like this before? As I mentioned, my application works fine - this only occures for /hystrix.stream. I've used the Chrome Postman plugin to add the Accept and Content-Type = application/json headers to the request - both without success. As far as I know, requests to this servlet do not have any header requirements</p>
  
  <p>Thanks for the help.</p>