2

Disclaimer: there is a lot of information on similar topics. In our case it works as expected without AWS ELB (Elastic Load Balancer), i.e. when the client drops, ServletOutputStream.flush() throws IOException.

Setup: we have an instance running Tomcat 7 (Java 1.7) behind ELB (HTTPS:443 -> HTTP:8080). The servlet streams data to the client through HTTP long lived connection.

Problem: when the client disconnects, the server keeps streaming data, i.e. ServletOutputStream.flush() or .write() does not throw IOException. The ELB kind of "buffers" the connection (we can see it with IpTraf monitor), so from the Tomcat side it appears as the client is still there. Without the ELB, IOException is thrown properly, so the servlet can stop streaming. We have disabled connection draining and reduced connection timeout to 1 sec, we also reduced all timeouts on Tomcat's HTTP Connector including KeepAlive to just few seconds. Nothing helps.

Question: is there anything we can do with the ELB configuration / Tomcat / Java side to allow disconnection detection in this setup?

Boris Krassi
  • 193
  • 1
  • 9
  • Does running the ELB in TCP mode behave any differently? – Michael - sqlbot Feb 24 '16 at 00:04
  • @Michael: yes, it is a bit different in this configuration SSL:443 -> TCP:8080 (which is no good for our application because it does not support session stickiness). Based on IpTraf monitor, the TCP connection from ELB to the instance gets CLOSED, but the TCP connection from the instance to the ELB remains open and streaming data. – Boris Krassi Feb 24 '16 at 13:12

1 Answers1

0

We had the same kind of problem (but in .NET with IIS). We seem to have solved it by switching from the classic ELB to the Application ELB. Now writing to the output stream of a closed connection gives an exception, where first (on classic ELB) it didn't.

Hope this helps anyone running into the same problem

Tjipke
  • 408
  • 3
  • 12