JSAMP hub and localhost hostname

Pierre Fernique fernique at simbad.u-strasbg.fr
Tue Dec 2 02:55:06 PST 2008


Hi all,

My experience with the GLU project: surprisingly, it is difficult to 
have a simple method for getting a correct full local hostname and it is 
worst if you want to be sure that this hostname is correctly registered 
in the DNS (correct alias for the IP). I strongly suggest to use 
127.0.0.1 as PLASTIC/SAMP is presently really designed for local access. 
The 127.0.0.1 is managed at the IP stack level. So it is always 
responding even if you have several network cards or no card at all. It 
is constant (DHCP potential problem). And it should solve some potential 
firewall filter problems and potential security holes.

In the future, if we want to extend SAMP for remote connections we could 
invent a kind of gateway plugged on the hub and managing all the 
required remote registrations, remote authentifications ... I wonder if 
a dedicated SAMP client could do this job?

But in any case, by using 127.0.0.1, we will fix a lot of potential 
problems.
Cheers,
Pierre


Mark Taylor a écrit :
> On Tue, 2 Dec 2008, boch at vizir.u-strasbg.fr wrote:
>
>> Hi Mark,
>>
>> I've been testing and playing with (J)SAMP the last days, and I had 
>> the following problem :
>>
>> - let's pretend I am connected to a wireless network whose DHCP 
>> server gives me hcp-131-176-166-130.esac.esa.int as hostname
>>
>> - if I launch a JSAMP hub, the lockfile will have the following line :
>> samp.hub.xmlrpc.url=http://dhcp-131-176-166-130.esac.esa.int:55823/
>>
>> - now, if I disconnect from this network, and startup Aladin, it 
>> won't be able to connect to the hub because it won't be able to 
>> resolve the XML-RPC URL hostname.
>>
>> So, my question is : wouldn't it be safer to use the IP address 
>> instead of the hostname ?
>>
>> Subsidiary question : I noticed that sometimes, the Java method 
>> InetAddress.getLocalHost() throws an UnknownHostException (I use this 
>> method to set the callback URL of Aladin). In such a case, how safe 
>> is it to consider 127.0.0.1 to be the localhost IP address ?
>> Though I am not a network expert at all, I feel this would do the 
>> right thing most of the time. Any opinion on that ?
>
> Thomas,
>
> good questions, not all of which I have good answers to. I'm bouncing 
> this onto the apps-samp list in case others have thoughts
> or benefit from the discussion.
>
> First, this is an issue that we've come up against before in AstroGrid 
> in relation to the AG PLASTIC hub and the VODesktop/AR
> XML-RPC server.  The consensus seems to be that there is no best way 
> to do it - any single approach will fail under some network
> setups (see the followup bugzilla tickets in the snippet below).
> With that in mind, I've tried to cover all bases in JSAMP
> by making this configurable.  When JSAMP writes the hostname into
> the hub lockfile, it uses the SampUtils.getLocalhost() utility method,
> whose javadocs and source currently read like this:
>
>     public static final String LOCALHOST_PROP = "samp.localhost";
>     ...
>
>     /**
>      * Returns a string denoting the local host to be used for 
> communicating
>      * local server endpoints and so on.
>      *
>      * <p>This is normally obtained by calling
>      * <pre>
>      *    java.net.InetAddress.getLocalHost().getCanonicalHostName()
>      * </pre>
>      * but this behaviour can be overridden by setting the
>      * {@link #LOCALHOST_PROP} system property to the string which should
>      * be returned instead.  Sometimes local network issues make it
>      * advantageous to use some non-standard string such as "127.0.0.1".
>      * See, for instance, AstroGrid bugzilla tickets
>      * <a href="http://www.astrogrid.org/bugzilla/show_bug.cgi?id=1799"
>      *    >1799</a>,
>      * <a href="http://www.astrogrid.org/bugzilla/show_bug.cgi?id=2151"
>      *    >2151</a>.
>      *
>      * @return  local host name
>      */
>     public static String getLocalhost() {
>         String hostname = System.getProperty( LOCALHOST_PROP, "" );
>         if ( hostname.length() == 0 ) {
>             try {
>                 hostname = 
> InetAddress.getLocalHost().getCanonicalHostName();
>             }
>             catch ( UnknownHostException e ) {
>                 hostname = "127.0.0.1";
>             }
>         }
>         return hostname;
>     }
>
> So, if you understand the problem you can fix it by running the hub
> with the system property samp.localhost=131.176.166.130 or whatever
> you reckon will work.
>
> This is a good start, but the trouble is people who don't understand
> the problem (=most users) won't know what's up or how to fix it. So 
> there might be improvements to be made in advertising this 
> functionality or in choosing a safer default.  Ideas from anyone who, 
> after reading the bugzilla tickets referenced above, thinks they might 
> have a contribution, are welcome.
>
> Mark
>




More information about the apps-samp mailing list