1 2 Previous Next 16 Replies Latest reply on Dec 12, 2013 9:37 PM by klmurty

    Multicast communication does not work with Stand-alone cluster

    fastbucks

      Hi,

       

      Multicast communication does not seem to work in a standalone cluster although I have UDP enabled. On my local machine, it works. However, in the cluster that I set up on separate machines, it is not working. Here are my configuration and code snippets.

       

      Configuration (hornetq-jms.xml):

         <connection-factory name="NettyConnectionFactory">

            <discovery-group-ref discovery-group-name="dg-group1"/>

             <entries>

                <entry name="/ConnectionFactory"/>

              </entries>

              <client-id>1000</client-id>

          </connection-factory>

       

       

      Client code:

          connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(

              new DiscoveryGroupConfiguration(231.7.7.7, 9876), JMSFactoryType.CF);

          connectionFactory.setReconnectAttempts(-1);

          connectionFactory.getDiscoveryGroupConfiguration().setDiscoveryInitialWaitTimeout(100000);

       

      The error message that I see is: [errorCode=3 message=Timed out waiting to receive initial broadcast from cluster]. It comes from ServerLocatorImpl.java line 569.

       

      Am I missing anything here?

       

      Separately, I wrote two simple java classes to test multicasting - one to join the multicast group and the other one to send a message to the group. That works with the cluster I set up with two separate machines. I am confused why HornetQ's client is not able to establish a connection with the multicast group.

       

      Appreciate any help.

       

      Thanks.

       

      PS: I did see a thread on the forum about connection issue with multicasting. The answer was to enable UDP. For me, it has been turned on. Looks like it is beyond that point for me.

        • 1. Re: Multicast communication does not work with Stand-alone cluster
          gaohoward

          If you can upload a test, that'll be a great help for us to investigate it.

           

          Howard

          • 2. Re: Multicast communication does not work with Stand-alone cluster
            fastbucks

            All I am doing is very simple. I have 3 machines A, B, and C. On A, I have the HornetQ client running the (partial) code I posted in my original post. Of course there is code for posting messages etc. Machines B and C have stand-alone clustered HornetQ nodes. UDP is enabled for all of them. The client on machine A creates a connection with the multicast address for B and C as follows:

             

                connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(

                    new DiscoveryGroupConfiguration(231.7.7.7, 9876), JMSFactoryType.CF);

                connectionFactory.setReconnectAttempts(-1);

                connectionFactory.getDiscoveryGroupConfiguration().setDiscoveryInitialWaitTimeout(100000);

             

                try {

                  jmsConnection = (HornetQConnection) connectionFactory.createConnection(userName, pwd);

                  session = (HornetQSession) jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                } catch (JMSException je) {

                  logger.error("JMS issue with the HornetQ artifacts.", je);

                }

             

            The client hangs when it tries to create the connection from the connectionFactory and times out. I am running HornetQ 2.2.5.Final. The thread in DiscoveryGroupImpl.java at line 307, is trying to join the multicast group with socket.receive(packet);. For whatever reason, it is not able to join. Obviously, the waitForBroadcast() method times out.

             

            Now, I wrote a simple java client to join the multicast group and another client to send a message to the group. With the same multicast IP address that I mentioned above, the java clients work perfectly fine joining the group, sending message, and getting the message. Not sure why the thread in DiscoveryGroupImpl is not able to join the multicast group.

            • 3. Re: Multicast communication does not work with Stand-alone cluster
              ataylor

              I think this has ben discussed several times in the forums, however see http://community.jboss.org/wiki/RunningAHornetQClusterUsingDiscoveryDoesntWork

              • 4. Re: Multicast communication does not work with Stand-alone cluster
                fastbucks

                I checked the link http://community.jboss.org/wiki/RunningAHornetQClusterUsingDiscoveryDoesntWork but the scenarios do not seem to apply to my case. As I mentioned in my earlier post, I have these two utilities that I am pasting below. I run the JoinHornetQ to join the multicast group and PingHornetQ to send a message to the multicast group. When I run these classes with the HornetQ cluster that I am having problem with all machines remaining the same, the java clients work as expected.

                 

                 

                JoinHornetQ.java

                 

                import java.io.IOException;

                import java.net.DatagramPacket;

                import java.net.InetAddress;

                import java.net.MulticastSocket;

                 

                 

                public class JoinHornetQ {

                 

                 

                  /**

                   * @param args

                   */

                  public static void main(String[] args) {

                    String groupName = "232.7.7.7";

                    int port = 9872;

                    receivePackets(groupName, port);

                  }

                 

                 

                  private static void receivePackets(String groupName, int port) {

                    try {

                      MulticastSocket socket = new MulticastSocket(port);

                      InetAddress groupAddress = InetAddress.getByName(groupName);

                      socket.joinGroup(groupAddress);

                 

                 

                      DatagramPacket packet;

                      for (int i = 0; i < 50000; i++) {

                        byte[] buf = new byte[1024];

                        packet = new DatagramPacket(buf, buf.length);

                        socket.receive(packet);

                        String received = new String(packet.getData());

                        System.out.println("Data received: " + received);

                      }

                      socket.leaveGroup(groupAddress);

                      socket.close();

                    } catch (IOException e) {

                      // TODO Auto-generated catch block

                      e.printStackTrace();

                    }

                  }

                 

                 

                }

                 

                 

                PingHornetQ.java

                 

                import java.io.IOException;

                import java.net.DatagramPacket;

                import java.net.DatagramSocket;

                import java.net.InetAddress;

                import java.net.MulticastSocket;

                 

                 

                public class PingHornetQ {

                 

                 

                  /**

                   * @param args

                   */

                  public static void main(String[] args) {

                    int port = 9872;

                    String groupName = "232.7.7.7";

                    sendMessage(groupName, port);

                  }

                 

                 

                  private static void sendMessage(String groupName, int port) {

                    byte[] outbuf = new byte[1024];

                    outbuf = "This will be great, iA".getBytes();

                    try {

                      DatagramSocket socket = new DatagramSocket();

                      InetAddress broadcastAddress = InetAddress.getByName(groupName);

                      DatagramPacket packet = new DatagramPacket(outbuf, outbuf.length, broadcastAddress, port);

                      socket.send(packet);

                    } catch (Exception e) {

                      e.printStackTrace();

                    }

                  }

                 

                 

                }

                • 5. Re: Multicast communication does not work with Stand-alone cluster
                  ataylor

                  I dont really gwet what your client is, its not HornetQ! If the socket.receive(packet) is not working its becasue either UDp isnt enabled on the cluster or you dont have a loopback address when they are all on the same machine. Either that or your UDP config is wrong. This is not really hornetq code.

                   

                  I would start by making sure the excamplesd work, then if you find an issue prepare us a test we can easily run.

                  • 6. Re: Multicast communication does not work with Stand-alone cluster
                    fastbucks

                    What I am basically saying is that the HornetQ cluster is the same (two HornetQ stand-alone nodes on two separate machine). Now, on a third machine, instead of running my HornetQ client, I am running the sample java files I posted. These sample java files are able to join the multicast group of HornetQ nodes and also send packets to the group. Hope that clarifies what I am trying to do.

                     

                    As for the examples, they run on the same machine. I would not be able to test them with the topology I am working.

                    • 7. Re: Multicast communication does not work with Stand-alone cluster
                      ataylor

                      can you post all your config, thats all i can think can be wrong

                      • 8. Re: Multicast communication does not work with Stand-alone cluster
                        fastbucks

                        Please find the configuration files attached. Do you see anything wrong? Appreciate any input. Thanks.

                        • 9. Re: Multicast communication does not work with Stand-alone cluster
                          fastbucks

                          The interesting thing is if I have a one node stand-alone cluster on my local machine, it works. Only when the cluster is on different machine(s), HornetQ client is not receiving packets.

                          • 10. Re: Multicast communication does not work with Stand-alone cluster
                            fastbucks

                            I am trying TransportConfiguration instead of DiscoveryGroupConfiguration but that does not seem to work either. I do not have firewall enabled on any server. Appreciate any help.

                            • 11. Re: Multicast communication does not work with Stand-alone cluster
                              ataylor

                              make sure that you are binding the acceptors and connectors to a reachable addreess, i.e. not localhost which is the default in your  configuration.

                              • 12. Re: Multicast communication does not work with Stand-alone cluster
                                ataylor

                                also your test program is using a different port so I''m not sure how it can receive anythuing from another node, maybe its receiving its own broadcast. Again make sure UDP is enabled on the network.

                                • 13. Re: Multicast communication does not work with Stand-alone cluster
                                  fastbucks

                                  The acceptors and connectors have the right ip address in my deployment. Now, I connected the debugger to HornetQ server. The debugger gets stuck in BroadcastGroupImpl start() method at this line:

                                   

                                        started = true;

                                   

                                  It is line 129. Not sure what is happening at that point. I am not providing local bind address and port. Keeping it default. Ideas?

                                  • 14. Re: Multicast communication does not work with Stand-alone cluster
                                    ataylor

                                    That cant be happening, there is no syncronisation there and its a simple line of code

                                    1 2 Previous Next