Skip to main content

Multicast error

  5 posts   Feedicon  
Replies: 4 - Last Post: June 09, 2011 10:15
by: k0nr4d
showing 1 - 5 of 5
Posted: April 29, 2011 13:22 by livonthedge
I was first working with an older version of the cajo.jar, constructor as follows:

 Cajo(int port, String host, String Client) 


everything worked fine.

I then started to experiment with the most recent version of Cajo with the constructor as follows:

 Cajo(int ttl, int port, String host) 


I would then get the below error. When I went back over to the older version of the cajo.jar I would then get the error when I ran that one as well.

I am fairly new to cajo and rmi and would appreciate it if anyone was able to give me a high level explanation as to what is going on.

Thanks so much.

java.net.SocketException: bad argument for IP_MULTICAST_IF: address not bound to any interface
        at java.net.PlainDatagramSocketImpl.socketSetOption(Native Method)
        at java.net.PlainDatagramSocketImpl.setOption(PlainDatagramSocketImpl.java:309)
        at java.net.MulticastSocket.setInterface(MulticastSocket.java:424)
        at gnu.cajo.utils.Multicast.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:662)
java.net.SocketException: bad argument for IP_MULTICAST_IF: address not bound to any interface
        at java.net.PlainDatagramSocketImpl.socketSetOption(Native Method)
        at java.net.PlainDatagramSocketImpl.setOption(PlainDatagramSocketImpl.java:309)
        at java.net.MulticastSocket.setInterface(MulticastSocket.java:424)
        at gnu.cajo.utils.Multicast.announce(Unknown Source)
        at gnu.cajo.Cajo.<init>(Unknown Source)
        at myCajoServerTest.MyCajoServerTest.main(MyCajoServerTest.java:28)
Posted: April 29, 2011 19:03 by John Catherino
Let's figure this out!

The current version of the Cajo object has a constructor as follows:

Cajo(int ttl, String address, int port)

Is this the one you are using? (It is available is source form here.) The stack trace seems to indicate that the address you're providing is not a valid multicast address, are you sure what you are providing is? The IANA cmulticast address for cajo is: 224.0.23.162.

Possibly this may help: here is a test I use for the cajo object, does it work for you?

Server.java:

import gnu.cajo.Cajo;

class Service {
   public static String getMessage(String name) { return "Hello " + name; }
}

public class Server {
   public static void main(String[] args) throws Exception {
      Cajo cajo = new Cajo();
      cajo.export(new Service());
      System.out.println("Server running");
   }
}


Client.java:

import gnu.cajo.Cajo;

interface MyService {
   Object getMessage(String id);
}

public class Client {
    public static void main(String[] args) throws Exception {
        Cajo cajo = new Cajo();
        Thread.currentThread().sleep(500); // allow some discovery time
        Object results[] = cajo.lookup(MyService.class);
        System.out.println("Objects found: " + results.length);
        if (results.length > 0) {
           MyService service = (MyService)cajo.proxy(results[0], MyService.class);
           System.out.println("Message = " + service.getMessage("client"));
        }
        System.exit(0);
    }
}


I'll be happy to help you work through this.

John
Posted: April 29, 2011 19:45 by livonthedge
This seemed to be related to my environment and the same code I was having issues with along with your sample ran fine on another machine.

Not sure what the issue was but have things running now.

Thank you
Posted: May 10, 2011 12:33 by k0nr4d
JVM has some sort of a problem with handling IPv6 multicasting. Disabling the IPv6 stack by adding:

-Djava.net.preferIPv4Stack=true

to your JAVA_OPTS provides a workaround.
Guys from the JBoss community reproduced this on both Ubuntu and Windows Server 2003 so
this seems like a bigger issue ( http://community.jboss.org/thread/62637?tstart=0 )
Posted: June 09, 2011 10:15 by k0nr4d
I've had a second take on this problem while trying to launch my application across a cluster of Linux PC's.

I've taken the interaction from John's example code. At first, I've run into the IP_MULTICAST_IF error too. Using -Djava.net.PreferIPv4Stack=true takes care of the error and additionally allows you to run any number of Cajo instances on localhost, but doesn't even pretend to work on the network.

With a bit of trial and error and network sniffing, I discovered that the JVM finds it hard to pick any multicasting interface if it has more than one to choose from. This was obviously the case, as any networked Linux box has at least two of them (the loopback interface and your network card). Preferring the IPv4 stack somehow solves the difficulty by binding to lo. To make it work on a real host, you have to manually bind to one of your network interfaces, i.e. call this before instantiating Cajo:

Remote.config(sendHost, 1198, sendHost, 1198);



In my case, sendHost resolved to the LAN IP address.

Replies: 4 - Last Post: June 09, 2011 10:15
by: k0nr4d
 
 
Close
loading
Please Confirm
Close