I have a web application (.war file) running under Tomcat. It is a proxy between my c++ client/server applications. Once HTTP request (from the client) is received by web application, it propagates request to the server and sends response back to the client once it is ready. Server may need long time before it produces some data to send to the client (also it can send data by chunks with really long delays etc.).
My question is. Is there a way to detect client disconnect before the time server has something ready to be written to the output stream? In case if server writes something after client's disconnect, obviously I will get an exception and can handle it properly. But my goal is to avoid waiting for the server to produce some data to write, to find client disconnect.
I believe this is a common issue people face and there should be a graceful solution for this. Can you advise?