Home Help Center

Connection establishment and DNS

sportlanesportlane Member Mikael SuviOrganization: Skype Ltd.Project: Skype
Hi,

From Ice documentation under paragraph 37.3.1 I can read that:

"The proxy performs the following steps to derive its endpoint list:
...
3. Perform DNS queries to convert host names into IP addresses, if necessary. For a multi-homed host name, the proxy adds a new endpoint for each address returned by the DNS query.
"

I am failing to get this described functionality working. I have the following lines in my /etc/hosts

===
X.X.X.1 foo # IP of machine that has no service running
X.X.X.2 foo # valid running service
===

With this setup any attempt to do (un)checkedCast for object "test: tcp -h foo -p 2000" fails with:

Network.cpp:664: Ice::ConnectionRefusedException:

Although the documentation gives an impression it should try the other X.X.X.2 IP to establish connection. What could be wrong?

Mikael Suvi

Comments

  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    Multi-homed hosts only works as far as we know when the hostnames are registered with a DNS server and not just entered in /etc/hosts. This is because getaddrinfo(), which Ice uses internally to get the IP addresses, does not cause all of /etc/hosts to be parsed to find matches. It just proceeds until it finds the first match. Thus it will use whichever address you place first in /etc/hosts.

    At least this is the case on platforms we have tested. What platform are you using?
  • sportlanesportlane Member Mikael SuviOrganization: Skype Ltd.Project: Skype
    Hi,

    Multiple hosts added to /etc/hosts file will be returned by getaddrinfo() as separate hosts. It behaves this way at least on linux and os x.

    Looking at the file Ice/Network.cpp (3.3.0) I fail to notice any functionality that would iterate through the result-set returned by getaddrinfo() and add new endpoint for each host. Maybe looking from wrong place.

    Mikael Suvi
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Mikael,

    We do loop through the addresses returned by getaddrinfo (check the getAddresses method implemented in Network.cpp).

    You're right though, it looks like getaddrinfo can indeed return the multiple IP addresses associated with the host name specified in /etc/hosts. However, it looks like this feature is very OS dependent. It works for me on Mac OS X but it doesn't on Linux RedHat Enterprise Linux 4 or 5 and SuSE Linux Enterprise 10.1 (I'm not sure whether or not this is supported with other Linux distributions).

    I tried with Ice 3.3.1 on Mac OS X and an Ice client correctly tries to connect to all the IP addresses associated to the host name (I used the hello client from demo/Ice/hello to try it out by changing the proxy configuration to use a host name specified in /etc/hosts with multiple IP addresses and starting the client with --Ice.Trace.Network=2).

    Cheers,
    Benoit.
  • sportlanesportlane Member Mikael SuviOrganization: Skype Ltd.Project: Skype
    Thank you! Upgrading to 3.3.1 resolves the issue.
Sign In or Register to comment.