How to configure WildFly and JBoss EAP to use TCPPING

This article will teach you how to use TCPPING in combination with TCP/UDP Unicast as transport and a static list of cluster members’s addresses.

If you are using WildFly 14 or newer, the recommended way to do that is to use the <socket-discovery-protocol /> element. This element points to set the socket bindings (one for each cluster note). This decouples the cluster definition from the JGroups configuration:

<stack name="tcpping">
    <transport type="TCP" socket-binding="jgroups-tcp"/>
    <socket-discovery-protocol type="TCPPING" socket-bindings="jgroups-host-a jgroups-host-b"/>
    <protocol type="MERGE3"/>
    <protocol type="FD_SOCK"/>
    <protocol type="FD_ALL"/>
    <protocol type="VERIFY_SUSPECT"/>
    <protocol type="pbcast.NAKACK2"/>
    <protocol type="UNICAST3"/>
    <protocol type="pbcast.STABLE"/>
    <protocol type="pbcast.GMS"/>
    <protocol type="MFC"/>
    <protocol type="FRAG2"/>
</stack>

Then in your socket-binding-group define the list of cluster members:

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">

    <!-- other configuration here -->
    <outbound-socket-binding name="jgroups-host-a">
        <remote-destination host="localhost" port="7600"/>
    </outbound-socket-binding>
    <outbound-socket-binding name="jgroups-host-b">
        <remote-destination host="localhost" port="7750"/>
    </outbound-socket-binding>
</socket-binding-group>

You can change to the default channel’s stack to use tcpping as follows:

/subsystem=jgroups/channel=ee:write-attribute(name=stack,value=tcpping)

Legacy TCPPING configuration

If you are using an older version of WildFly or JBoss EAP 6, then you need to use properties to specify your static cluster composition.In the following example we have configured as default stack tcpping for a cluster made up of two nodes listening on the IP Addresses 192.168.10.1 and 192.168.10.2 with the default tcp port 7600:

<subsystem xmlns="urn:jboss:domain:jgroups:2.0" default-stack="tcpping">
	<stack name="tcpping">
		<transport type="TCP" socket-binding="jgroups-tcp"/>
		<protocol type="TCPPING">
			<property name="initial_hosts">192.168.10.1[7600],192.168.10.2[7600]</property>
			<property name="port_range">10</property>
			<property name="timeout">3000</property>
			<property name="num_initial_members">2</property>
		</protocol>
		<protocol type="MERGE2"/>
		<protocol type="FD_SOCK" socket-binding="jgroups-tcp-fd"/>
		<protocol type="FD"/>
		<protocol type="VERIFY_SUSPECT"/>
		<protocol type="BARRIER"/>
		<protocol type="pbcast.NAKACK"/>
		<protocol type="UNICAST2"/>
		<protocol type="pbcast.STABLE"/>
		<protocol type="pbcast.GMS"/>
		<protocol type="UFC"/>
		<protocol type="MFC"/>
		<protocol type="FRAG2"/>
		<protocol type="RSVP"/>
	</stack>
</subsystem>
  • initial_hosts is a comma delimited list of hosts to be contacted for initial membership.
  • num_initial_members specifies the maximum number of responses to wait for unless timeout has expired. The default is 2.
  • TCPPING will try to contact both 192.168.10.1 and 192.168.10.2, starting at port 7600 and ending at port 7600 + the port_range, in the above example ports 7600 – 7610.

Legacy TCPPING from the CLI

Here is a script which can be used to create the TCPPING stack directly from the CLI:

connect
batch
/subsystem="jgroups"/stack="tcpping":add()
/subsystem="jgroups"/stack="tcpping":add-protocol(type="TCPPING")
/subsystem="jgroups"/stack="tcpping"/protocol="TCPPING"/property="initial_hosts":add(value="192.168.10.1[7600],192.168.10.2[7600]")
/subsystem="jgroups"/stack="tcpping"/protocol="TCPPING"/property="port_range":add(value="10")
/subsystem="jgroups"/stack="tcpping"/protocol="TCPPING"/property="timeout":add(value="3000")
/subsystem="jgroups"/stack="tcpping"/protocol="TCPPING"/property="num_initial_members":add(value="2")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="MERGE2")
/subsystem="jgroups"/stack="tcpping":add-protocol(socket-binding="jgroups-tcp-fd",type="FD_SOCK")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="FD")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="VERIFY_SUSPECT")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="BARRIER")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="pbcast.NAKACK")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="UNICAST2")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="pbcast.STABLE")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="pbcast.GMS")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="UFC")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="MFC")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="FRAG2")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="RSVP")
/subsystem="jgroups"/stack="tcpping"/transport="TRANSPORT":add(socket-binding="jgroups-tcp",type="TCP")
run-batch

Configuring TCPPING with UDP Unicast

A special use case is a cluster which relies on UDP but, due to policy restrictions, you cannot use multicast. In this case, you can configure UDP Unicase. Behind the hoods, Unicast uses TCP (Transmission Control Protocol) for communications while Multicast uses UDP (User Datagram Protocol).

In order to use UDP unicast in this scenario, you can set the property ip_mcast to false in the UDP transport element. For example:

 <stack name="udp">
    <transport type="UDP" socket-binding="jgroups-udp">
        <property name="ip_mcast">false</property>
    </transport>
    <protocol type="TCPPING">  
        <property name="initial_hosts">127.1.1.1 [7600], 127.1.1.1[7600]</property>
        <property name="port_range">0</property>
        </protocol>                         
        <protocol type="MERGE3"/>
        <socket-protocol type="FD_SOCK" socket-binding="jgroups-udp-fd"/>  
        <protocol type="FD_ALL"/>
        <protocol type="VERIFY_SUSPECT"/>
        <protocol type="pbcast.NAKACK2"/>
        <protocol type="UNICAST3"/>
        <protocol type="pbcast.STABLE"/>
        <protocol type="pbcast.GMS"/>
        <protocol type="UFC"/>
        <protocol type="MFC"/>
        <protocol type="FRAG3"/>
</stack>
Found the article helpful? if so please follow us on Socials