Archived

This forum has been archived. Please start a new discussion on GitHub.

losing a network connection

Hi all,

I have one servant and one client running on the same platform (running Linux). Creation of the servant is based on the hostname (e.g. "platform1") instead of the IP address of the platform. The client periodically calls a RPC of the servant. The client creates a proxy to the servant only once (prior to the first RPC) by also using the hostname "platform1" and reuses that proxy during every consecutive RPC.

All goes well while the network connection remains up. Whenever I disconnect the platform from the network then the client cannot reach the servant anymore although the client and servant are running on the same platform. Could it be that DNS is queried during every RPC to resolve the hostname "platform1"?

Regards,
Joan

Comments

  • You should try to explicitly use loopback. Use -h 127.0.0.1 for your endpoints, then there is no DNS lookup at all. You can also set Ice.Default.Host=127.0.0.1 and no -h option for your endpoints.
  • Ok, using loopback solves my problem described above when it applies a client and servant running on the same platform. But when I expand my application a little by letting a client on "platform2" RPC the servant on "platform1" then the client on platform2 cannot reach the servant since it cannot connect to the servant's endpoints. That's why I'm using the hostname instead of loopback for my servants' endpoints.

    It seems that DNS is still required during consecutive RPCs regardless a client has successfully created a proxy of a local servant previously. To put in other words, can I by-pass any DNS traffic during a RPC on a local platform when the proxy to a servant has already been successfully created (using hostname instead of loopback)?
  • A DNS lookup is only needed when a connection is established, not for every RPC call (that would mean a huge overhead). Once a connection is established, no further DNS lookups are needed until the connection is terminated and a new one is established.

    You can trace the establishment and closure of connections with Ice.Trace.Network=2. Note that Ice by default closes connections that have been idle for a certain time, and re-establishes them on demand. You can disable this behavior with Ice.ConnectionIdleTime=-1.

    Also note that on some platforms, if you disconnect the network card, all connections that use the IP address for that network card are reset. By tracing network connections as explained above, you can find out what the exact behavior of your platform is.

    You can also use multiple endpoints, one for the loopback, and one for the network card.
  • By the way, if looking up the local hostname results in a remote DNS call, then most likely either your hostname or your /etc/hosts file is not set up correctly. Ice does a gethostbyname(gethostname()) to get the IP address of the default interface of the local host. Configured correctly, gethostname() should return a name that can be found in /etc/hosts, and therefore gethostbyname() doesn't have to ask a name server.