[undertow-dev] how to implement request processing timeout

Stuart Douglas sdouglas at redhat.com
Sun Jul 15 21:48:04 EDT 2018


So there are a few options, but if you actually want to generate a HTTP
response instead of just dropping the connection then your application code
is going to have to take some responsibility.

If all you want to do is drop the connection then just scheduling a task
that does exchange.getConnection().close() is fine, no HTTP response will
be returned to the client.

If you want to actually send a response to the client then you are going to
have to have some kind of lock/CAS that prevents your application from
writing once the timeout has taken effect.

Are you using the Servlet API or the HttpServerExchange API? The best way
to approach this is a bit different depending on what you are doing.

Stuart




On Sun, Jul 15, 2018 at 11:50 AM Stan Rosenberg <stan.rosenberg at acm.org>
wrote:

> Apologies if this question has already been answered elsewhere; closest I
> could find is this thread:
> http://lists.jboss.org/pipermail/undertow-dev/2014-August/000898.html
>
> HttpServerExchange cannot be manipulated from multiple threads (without
> locking).  Thus, dispatch and executeAfter wouldn't work if the goal is to
> end the exchange after the max. time to process (request) has been exceeded.
>
> I can implement this timeout mechanism using out-of-band thread executor
> but was hoping there is a more efficient way provided by the framework.
> Thanks.
>
> Best,
>
> stan
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20180716/bdc426c7/attachment-0001.html 


More information about the undertow-dev mailing list