Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RMI: weird conection problem using a single computer 1

Status
Not open for further replies.

LuckyStarr

Programmer
Sep 12, 2002
22
BR
Hi All,

I have a RMI server and client running in the same machine. They can connect normally, just using the 'localhost' address as the RMI address for retrieving the remote objects.

The problem occurs when the network goes down (more specifically, when I unplug the ethernet cable from the computer): the RMI connection between the server and the client is lost.

The question is: why is this happening? Shoudn't the RMI connection remain OK, even after the network goes down? After all, the server and clilent are in the same computer, same IP! I'm using the loop back address (127.0.0.1) to start the RMI connection, not the machine IP.

There is also a strange fact: when I run the server and client with the ethernet cable previously unplugged, no RMI connection problem occurs!

Scenario 1:

1- unplug the ethernet cable
2- run the server and client on same machine
3- connection OK

Scenario 2:

1- run the server and client on same machine
2- unplug the ethernet cable
3- connection PROBLEM

I don't understand. What could be happening?

Could you help me? I would be very grateful, you can save lots of work hours for me.

Ricardo.

"There is no Knowledge that is not power"
 
I expect is due to Java binds to the OS's DNS. When you unplug the eth cable & start the app, there is no external DNS, but when you unplug it during the server running, I expect it goes bananas as it cannot resolve names against the DNS (even though localhost shouldn't).

Another similar problem is this :

point your DNS server's name for "myserver" to 192.168.1.4 or something.
Start a Java server of some kind.
Change the DNS record to point at another IP.
Java caches the DNS, and still tries to use the old IP.

Solution - don't change your DNS entries, and don't unplug your network cable !


--------------------------------------------------
Free Database Connection Pooling Software
 
Unplugging the network cable is a TEST. I'm trying to test what would happen if the entire network stops working.

"There is no Knowledge that is not power"
 
>>> Unplugging the network cable is a TEST.

Your point being ? How does that change how Java binds to the network ? There's not need to SHOUT anyway.

>>>> I'm trying to test what would happen if the entire network stops working.

As I said earlier, you're RMI server will barf.

--------------------------------------------------
Free Database Connection Pooling Software
 
Hello sedj,

I was not shouting. I only wanted to emphasize the word TEST, just to let you know that I was not playing with the cable to see if some error happens! :)

Nothing personal buddy. That's Ok, and I thank you for your help.

What I really need to know is:

1. An RMI connection will always go down if the network stops working? Or my system have a problem by having the behavior of losing the RMI connection?

2. Will an RMI connection automatically reestablish itself if the network starts working suddenly? Or my system have a problem by having the behavior of not being able to reestablish the connection automatically?

3. Why does it works well if I unplug the network cable before running the server and client?
 
OK, lets try to remember that RMI is Remote Method Invocation, and as such is 99% of the time used to communicate over distributed environments (ie not one machine). So if your network goes down, then yes, you're stuffed. End of story.

In answer to "2." - if you're lucky, then yes. If you're not, then no. We have had times when the network has crashed, and the RMI file servers have been fine, no reboot needed. But again, I've seen it when it does not work. Basically, it has a lot to do with DNS, ARP tables, etc etc, stuff which RMI cannot control. The rule is this : if you're network dies, restart your applications as a matter of course.

In answer to "3.". (On localhost only) Well, I expect because there is no DNS or DHCP server available, it binds to the local address, and does not look for external DNS confirmation. But when would you seriously want to run an RMI server on just one machine - this is really a valid "test" for network failure.

--------------------------------------------------
Free Database Connection Pooling Software
 
That's it. Thanks very much sedj.

You've helped me a lot!

"There is no Knowledge that is not power"
 
Another idea:

Working on linux, we have a file
/etc/hosts
and another on:
/etc/host.conf

in the second one, there is written:
order hosts,bind

which means, to resolv an address, the file /etc/hosts is searched first, then the dns-server bind is asked.

in /etc/hosts you put static IPs and hostnames:
127.0.0.1 localhost.localmachine localhost
# ... more entries

On Windows, there is at least a hosts-file too in
%SYSTEM_ROOT%/system32/etc/
I guess.
A 'sample.hosts' is there too, as sample. :)

Perhaps writing your 'localhost' to that file will help.

Just an idea...

seeking a job as java-programmer in Berlin:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top