On 30/10/2023 22:25, Adwait Kumar Singh wrote:
Hi,

I am using the async Servlet API and NIO, by setting a ReadListener.

In the onError of the ReadListener, I am catching a SocketTimeoutException
and trying to send back an error code 408. Here is the simplified example
of what I am trying to do,

@Override
public void onError(Throwable failure) {
     if(failure instanceof SocketTimeoutException) {
         response.sendError(408);
         request.getAsyncContext().complete();
     }
}


However, Tomcat just refuses to send back the error I want and instead just
closes the connection. Am I missing something trivial or is this supposed
to be achieved in a different way?

I am using Tomcat 9.0.82 and the Http11NioEndpoint.

Has the response already been committed?

If not, a minimal (ideally a single servlet) web application that demonstrates the issue is often the easiest way for developers to re-create the problem.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to