The ideal solution is a combination of:
Only suppress the exception if you are certain the response generation had no side effects (e.g., database writes). If you already committed a transaction, you may need to roll back. The ideal solution is a combination of: Only
On the server, if your endpoint sleeps for 5 seconds then writes, you will reliably generate the broken pipe exception. For Servlet 3
For Servlet 3.0+ containers, use AsyncContext with a timeout callback to clean up if the client disconnects. Imagine you are a customer support agent (the server)
In the complex world of Java web application development, few stack traces cause as much confusion and frustration as the dreaded java.io.IOException: Broken pipe . Often appearing with the message ServletOutputStream failed to flush , this error can clutter server logs, mask underlying issues, and lead developers down a rabbit hole of debugging network infrastructure when the root cause is often much simpler.
Imagine you are a customer support agent (the server). You are on a phone call (the TCP connection) with a customer (the client).