1

It seems the instance-id in JSESSIONID is added when using standalone-ha.xml and not with standalone.xml, at least in my case:

# Standalone (instance-id not appended)

[mad@max bin]$ ./standalone.sh -Djboss.instance.id=node1 -Djboss.node.name=node1

[mad@max bin]$ curl -I http://127.0.0.1:8080/cluster-test/

HTTP/1.1 200 OK

Connection: keep-alive

X-Powered-By: Undertow/1

X-Powered-By: JSP/2.3

Set-Cookie: JSESSIONID=vEE6VucqPJBCbewsJceWKRjVAYvT1oxWy0ItAWwu; path=/cluster-test

Server: JBoss-EAP/7

Content-Type: text/html;charset=ISO-8859-1

Content-Length: 100

Date: Mon, 29 Jan 2018 18:06:22 GMT

# Standalone-HA (instance-id appended)

[mad@max bin]$ ./standalone.sh -c standalone-ha.xml -Djboss.instance.id=node1 -Djboss.node.name=node1

[mad@max bin]$ curl -I http://127.0.0.1:8080/cluster-test/

HTTP/1.1 200 OK

Connection: keep-alive

X-Powered-By: Undertow/1

X-Powered-By: JSP/2.3

Set-Cookie: JSESSIONID=5y1NCo9CM963aO5-OurRJAx2LMFl8wIi0AV3PJzm.node1; path=/cluster-test

Server: JBoss-EAP/7

Content-Type: text/html;charset=ISO-8859-1

Content-Length: 100

Date: Mon, 29 Jan 2018 18:03:38 GMT

As we can see in standalone mode there is no .node1 appended in JSESSIONID.

Undertow configuration in both cases:

<subsystem xmlns="urn:jboss:domain:undertow:3.1" instance-id="${jboss.instance.id}">                                                                                                                       

    <buffer-cache name="default"/>

    <server name="default-server">

        <http-listener name="default" socket-binding="http" redirect-socket="https"/>

        <host name="default-host" alias="localhost">

            <location name="/" handler="welcome-content"/>

            <filter-ref name="server-header"/>

            <filter-ref name="x-powered-by-header"/>

        </host>

    </server>

    <servlet-container name="default">

        <jsp-config/>

        <websockets/>

    </servlet-container>

    <handlers>

        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>

    </handlers>

    <filters>

        <response-header name="server-header" header-name="Server" header-value="JBoss-EAP/7"/>

        <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>

    </filters>

</subsystem>

This doesn't make sense to me. Sometimes all you have is an Apache/Nginx web server load balacing between two or more nodes, with no need for HA configuration. This creates a huge problem with sticky sessions, any suggestion?

In domain mode it happens the same: if you create a server-group from a default profile, no instance-id is added to the JSESSIONID.

Max Nicholson
  • 101
  • 1
  • 3
  • 8
  • From what you've seen, to me it's working as expected? Won't Apache or Nginx just look at a specific session id and and send it to the correct host, e.g. a sticky session? I didnt think they need a reference to the host itself to be part of the session id. Looking at some google results, it doesnt look like they need to be. – JGlass Jan 30 '18 at 13:43
  • Nope, it's not working as expected. The instance-id needs to be appended to the JSESSIONID when you work with mod_jk and sticky sessions for example. Instance-id must be the same as the worker name. – Max Nicholson Jan 30 '18 at 22:22
  • 1
    Configure instance-id on EAP 7: ------------------------------------------- You can use a CLI command like the following: /subsystem=undertow:write-attribute(name=instance-id,value=node1) Or modify your standalone or domain xml directly: When you have multiple instances sharing a single domain profile, set the instance-id to a system property, for example: – Anup Dey Jan 31 '18 at 07:05
  • 1
    Try using the below way to set unique instance-id per JBoss server instance in domain mode: Step-1: In the domain.xml file: – Anup Dey Jan 31 '18 at 07:05
  • 1
    Step-2: In the host.xml file: – Anup Dey Jan 31 '18 at 07:05
  • I already did that. Not working, either standalone mode or domain. – Max Nicholson Jan 31 '18 at 21:00

1 Answers1

0

Why introduce a new system property? The instance-id already defaults to the resolved ${jboss.node.name} expression. The property defaults to the hostname of the server when unspecified.

Paul Ferraro
  • 326
  • 1
  • 3
  • The problem it is not getting appended at the end of the JSESSIONID, not if we modify the normal behaviour. – Max Nicholson Feb 09 '18 at 19:54
  • We have tests that validate that the route is appended for non-distributed web applications, so there must be something wrong with your setup. See: https://github.com/wildfly/wildfly/blob/master/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/web/NonDistributableTestCase.java – Paul Ferraro Feb 13 '18 at 22:56
  • The Jboss is just unzipped and the test app deployed with no additional setup at Application Server level apart from instance-id="${jboss.instance.id} that is added in Undertow subsystem. But I suppose there must be something, somewhere. – Max Nicholson Feb 15 '18 at 06:22
  • Try removing your instance-id customization - it looks like it isn't resolving (rather, it seems to be resolving to an empty string). After that, you should at least see that the host name of the machine is getting appended to the JSESSIONID cookie. Once you get that working, customize the node name by setting the "jboss.node.name" system property. – Paul Ferraro Feb 16 '18 at 21:40