JSAMP hub and localhost hostname
Luigi Paioro
luigi at lambrate.inaf.it
Tue Dec 2 03:10:38 PST 2008
Thank you Mark for having posted this issue on the SAMP mailing list, it
gives me an answer to an old problem Alastair Allan had with SAMPy on
his laptop at home (maybe he remembers the problem), and I think the
only reasonable solution to adopt is that that you indicated. I've just
fixed SAMPy in order to try to get the host name using the standard
socket library, but if it fails than, by default it is used 127.0.0.1.
The next SAMPy release, that will come when the SAMP document v1.1 will
be promoted to Recommendation, will include this feature.
Luigi
Mark Taylor ha scritto:
> 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
>
--
Luigi Paioro
INAF - IASF Milano
Via Bassini 15, I-20133 Milano, Italy
Phone (+39) 02 23 699 470
Fax (+39) 02 26 660 17
Site http://www.iasf-milano.inaf.it/luigi/
More information about the apps-samp
mailing list