# Frequently Asked questions

## What is Advertise

Advertise allows autodiscovery of httpd proxies by the cluster nodes. It is done by sending multicast messages from httpd to the cluster. The httpd specialized module: mod_advertise sends UDP message on a multicast group, both mod_advertise and the cluster listener joined the multicast group and the cluster receives the messages.

Example for mod_advertise message:

    HTTP/1.0 200 OK
    Date: Wed, 08 Apr 2009 12:26:32 GMT
    Sequence: 16
    Digest: f2d5f806a53effa6c67973d2ddcdd233
    Server: 1b60092e-76f3-49fd-9f99-a51c69c89e2d
    X-Manager-Address: 127.0.0.1:6666
    X-Manager-Url: /bla
    X-Manager-Protocol: http
    X-Manager-Host: 10.33.144.3

The X-Manager-Address header value is used by the cluster logic to send information about the cluster to the proxy. It is the IP and port of the VirtualHost where mod_advertise is configured or URL parameter of the ServerAdvertise directive.

See Proxy Discovery in Configuration Properties and mod_advertise in Apache httpd configuration.

## What to do if I don't want to use Advertise (multicast):

In the VirtualHost receiving the MCPM of httpd.conf don't use any Advertise directive or use:

    ServerAdvertise Off

In mod_cluster-jboss-beans.xml add the addresses and ports of the VirtualHost to the proxyList property and set advertise to false, for example:

    <property name="proxyList">10.33.144.3:6666,10.33.144.1:6666</property>
    <property name="advertise">false</property>

In server.xml (with JBossweb/Tomcat)

    <Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" advertise="true"/>

## I am using Tomcat 7 / 6 what should I do:

See at the end of java configuration. You can't use the mod_cluster clustered mode with Tomcat so you get a loadbalancing logic similar to mod_jk but with a dynamic configuration.

## It is not working what should I do:

Most likely you have a configuration problem. Check the log of the cluster nodes and error_log of httpd.

### No error

That happens when Advertise is not working: The nodes don't get the advertise messages from httpd.

1. Check the modules are loaded and Advertise is started. In httpd.conf activate extended information display, add:

       AllowDisplay On

   When accessing to the mod_cluster_manager you should get something like:

   If not, go to the Minimal Example and add the missing directive(s).

2. Check that Advertise message are received on the cluster node. A small Java utility could be used to check Advertise. It is in the mod_cluster repository and can be compiled using javac. A compiled version can be found under in /opt/jboss/httpd/tools in the bundles. Run it using java Advertise multicastaddress port. The output should be something like:

       [jfclere@jfcpc java]$ java Advertize 224.0.1.105 23364
       ready waiting...
       received: HTTP/1.0 200 OK
       Date: Mon, 28 Jun 2010 07:30:31 GMT
       Sequence: 1
       Digest: df8a4321fa99e5098174634f2fe2f87c
       Server: 1403c3be-837a-4e76-85b1-9dfe5ddb4378
       X-Manager-Address: test.example.com:6666
       X-Manager-Url: /1403c3be-837a-4e76-85b1-9dfe5ddb4378
       X-Manager-Protocol: http
       X-Manager-Host: test.example.com

3. No Advertise messages

   Check firewall (don't forget the boxes firewall). Advertise uses UDP port 23364 and multicast addresse 224.0.1.105

4. Can't get Advertise messages

   Use ProxyList property. In case Advertise can't work you put the address and port of the VirtualHost used in httpd to receive the MCMP. In server/profile/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml

       <property name="proxyList">test.example.com:6666</property>

   or in server.xml:

       <Listener className="org.jboss.modcluster.container.catalina.standalone.ModClusterListener" proxyList="test.example.com:6666"/>

### Error in server.log or catalina.out

1. "IO error sending command ":

   Check firewall and error_log if there is nothing error_log then it is a firewall problem. If you have something like:

       18:36:14,533 INFO  [DefaultMCMPHandler] IO error sending command INFO to proxy jfcpc/10.33.144.3:8888

   You can use telnet hostname/address port to check by hands that it is OK for example:

       [jfclere@jfcpc docs]$ telnet 10.33.144.3 8888
       Trying 10.33.144.3...
       Connected to jfcpc.
       Escape character is '^]'.
       GET /
       <html><body><h1>It works!</h1></body></html>Connection closed by foreign host.

   Check that the address and port are the expected ones you may use ServerAdvertise On http://hostname:port, like:

       ServerAdvertise On http://localhost:6666

   Or use the servlet testhttpd in the testhttpd.war of the bundle (in /opt/jboss/httpd/tools). Install/deploy it in in the node and start the AS/Tomcat on the node, than access to the node directly and call /testhttpd/testhttpd

   If you don't get a similar page the output should help to find that is wrong.

### Error in error_log

1. "client denied by server configuration":

   The directory in the VirtualHost is not allowed for the client. If you have something like:

       Mon Jun 28 18:08:47 2010] [error] [client 10.33.144.3] client denied by server configuration: /

   You need to have something like:

       <Directory />
         Order deny,allow
         Deny from all
         Allow from 10.33.144.3
       </Directory>

## I have "HTTP/1.1 501 Method Not Implemented"

You need to configure EnableMCPMReceive in the VirtualHost where you received the MCMP elements in the Apache httpd configuration. Something like:

    <VirtualHost localhost:6666>
        <Directory />
         Order deny,allow
         Deny from all
         Allow from 127.0.0.1
        </Directory>
        ServerAdvertise on http://localhost:6666
        EnableMCPMReceive
    </VirtualHost>

## Redirect is not working:

When using http/https instead AJP proxyname, proxyhost and redirect must be configured in the Connector. Something like:

        <Connector port="8080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   proxyName="httpd_host_name"
                   proxyPort="8000"
                   redirectPort="443" />

## I have more than one Connector mod_cluster does use the right one

Mod_cluster tries to use the first AJP connector configured. If there isn't any AJP connector it uses the http or https that has the biggest maxthreads value. That is "maxThreads" in Tomcat and JBossAS4/5/6:

        <Connector port="8080" protocol="HTTP/1.1" maxThreads="201" />

Or "max-connections" in AS7: (32 * processor + 1 for native and 512 * processor + 1 for JIO).

        <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" max-connections="513" />

## Chrome can't diplay /mod_cluster_manager page

When using chrome with mod_cluster_manager the page is not displayed and the following error is displayed:

     Error 312 (net::ERR_UNSAFE_PORT): Unknown error.

you can change the port of the VirtualHost to 7777 or any value chrome accepts or add:

     --explicitly-allowed-ports=6666

to the start parameters of chrome.

## Using mod_cluster and SELinux.

Mod_cluster needs to open port and create shared memory and files, therefore some permissions have to be added, you need to configure something like:

    policy_module(mod_cluster, 1.0)

    require {
            type unconfined_java_t;
            type httpd_log_t;
            type httpd_t;
            type http_port_t;
            class udp_socket node_bind;
            class file write;
    }

    #============= httpd_t ==============

    allow httpd_t httpd_log_t:file write;
    corenet_tcp_bind_generic_port(httpd_t)
    corenet_tcp_bind_soundd_port(httpd_t)
    corenet_udp_bind_generic_port(httpd_t)
    corenet_udp_bind_http_port(httpd_t)

    #============= unconfined_java_t ==============
    allow unconfined_java_t http_port_t:udp_socket node_bind;

Put the above in a file for example mod_cluster.te and generate the mod_cluster.pp file (for example in Fedora 16):

    [jfclere@jfcpc docs]$ make -f /usr/share/selinux/devel/Makefile
    Compiling targeted mod_cluster module
    /usr/bin/checkmodule:  loading policy configuration from tmp/mod_cluster.tmp
    /usr/bin/checkmodule:  policy configuration loaded
    /usr/bin/checkmodule:  writing binary representation (version 14) to tmp/mod_cluster.mod
    Creating targeted mod_cluster.pp policy package
    rm tmp/mod_cluster.mod.fc tmp/mod_cluster.mod

The mod_cluster.pp file should be proceeded by semodule as root:

    root@jfcpc docs]# semodule -i mod_cluster.pp
    [root@jfcpc docs]#

## System properties to modify behaviour

org.jboss.modcluster.container.catalina.status-frequency (default: 1) send STATUS messages only 1/n periodic event (tomcat, jbossweb). The events occur every backgroundProcessorDelay (default 10 seconds).