[undertow-dev] Return HTTP Status 503 (Service Unvailable) until Web Application is available.

Thomas Darimont thomas.darimont at googlemail.com
Tue Jan 31 06:18:55 EST 2017


Quick update

In order to see the 503 Status code specified in the  default-response-code
attribute on the host-element
I had to remove the welcome-content filter by omitting the
   <location name="/" handler="welcome-content"/>
element.

However even with that config I see the following sequence from a repeated
curl sequence:
watch -n 2 curl -I http://localhost:8080/auth/

Server not started                                   : Connection Refused...
Server Started...                                     : HTTP/1.1 404 Not
Found
Begin Web App Deployment (Keycloak): HTTP/1.1 503 Service Unvailable
Web App Deployed                                : HTTP/1.1 200 OK

My example configuration
<subsystem xmlns="urn:jboss:domain:undertow:3.0">
    <buffer-cache name="default"/>
    <server name="default-server">
        <ajp-listener name="ajp" socket-binding="ajp"/>
        <http-listener name="default" socket-binding="http"
redirect-socket="https"/>

        <host name="default-host" alias="localhost"
default-response-code="503">
        </host>
    </server>
    <servlet-container name="default">
        <jsp-config/>
        <websockets/>
    </servlet-container>
    <handlers>
    </handlers>
    <filters>
    </filters>
</subsystem>

Cheers,
Thomas


2017-01-30 22:44 GMT+01:00 Thomas Darimont <thomas.darimont at googlemail.com>:

> Hi Stuart,
>
> thanks for the reply - I got a similar tip on the keycloak-user list
> however if I configure the default-response-code=503
> on the (single) host element of the undertow subsystem in Wildfly (10.1.0)
> and restart the server then I get a
> 404 but never a 503 when I access paths of an web app (keycloak) that is
> not fully initialized yet.
>
> Seems that I'm seeing the same behaviour as those folks:
> https://developer.jboss.org/thread/257526
>
> Is there anything else that one needs to configure to make this work?
>
> In the meantime I played a bit with alternative approaches e.g.:
> https://github.com/thomasdarimont/undertow-extensions
>
> Cheers,
> Thomas
>
> 2017-01-30 22:09 GMT+01:00 Stuart Douglas <sdouglas at redhat.com>:
>
>> You can add the default-response-code attribute in the host element of
>> the undertow subsystem to make it return 503 by default.
>>
>> Stuart
>>
>> On Mon, Jan 30, 2017 at 9:34 PM, Thomas Darimont
>> <thomas.darimont at googlemail.com> wrote:
>> > Hello group,
>> >
>> > (coss-post from keycloak-user Mailing List)
>> >
>> > the undertow servlet-container is started pretty early during the
>> startup of
>> > the
>> > wildfly application server. However the initialization of the keycloak
>> > server
>> > application might take a while to complete. Within this period requests
>> that
>> > are
>> > sent to the keycloak endpoints result in responses with HTTP Status Code
>> > 404.
>> >
>> > Is it possible to configure undertow to return a HTTP Status Code 503
>> > (Service Unvailable)
>> > until the keycloak application startup has completed?
>> >
>> > This would ease configuring load-balancers and to avoid showing a file
>> not
>> > found
>> > to users during server restarts.
>> >
>> > Cheers,
>> > Thomas
>> >
>> > _______________________________________________
>> > 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/20170131/1296e990/attachment-0001.html 


More information about the undertow-dev mailing list