FYI, I am doing the async processing on the Container thread itself, just that I yield the thread back if I can't read without blocking.
Based on the code here <https://github.com/apache/tomcat/blob/main/java/org/apache/coyote/AbstractProcessor.java#L121-L122>, I see that the error is only dispatched if the request is not being executed in the container thread. On Mon, Oct 30, 2023 at 3:25 PM Adwait Kumar Singh <adwsi...@gmail.com> 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. > > > Thanks, > Adwait. >