Pipe: Servletoutputstream Failed To Flush Java.io.ioexception Broken
The operating system detects that the receiving end is gone. When the Java process attempts to write to that closed socket, the OS sends a signal (SIGPIPE) or an error code, which the JVM translates into a java.io.IOException: Broken pipe .
Network devices between the client and server may enforce connection limits: The operating system detects that the receiving end is gone
A: Indirectly. If all threads are blocked, the request sits in a queue. By the time a thread picks it up, the client may have already timed out. If all threads are blocked, the request sits in a queue
For Servlet 3.0+ containers, use AsyncContext with a timeout callback to clean up if the client disconnects. If your servlet does a long database query
If your servlet does a long database query or heavy computation without sending any data (even chunks), the network device may assume the connection is dead and terminate it.
Properly setting timeouts at every layer is critical. The servlet container (e.g., Tomcat's connectionTimeout ), the reverse proxy (e.g., Nginx's proxy_read_timeout ), and even the network hardware should be aligned. A good rule of thumb is to ensure the client-facing timeout (e.g., browser or proxy) is longer than the expected maximum server processing time, or to design the application to send periodic progress updates that keep the connection alive.
long start = System.currentTimeMillis(); log.debug("Starting response write at {}", start); try { servletOutputStream.write(data); servletOutputStream.flush(); log.debug("Flush succeeded after {} ms", System.currentTimeMillis() - start); } catch (IOException e) { log.error("IO error after {} ms. Client likely disconnected.", System.currentTimeMillis() - start, e); }