aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes [RMI] How to et around the connection refused issue when using 2 different test machines Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "[RMI] How to et around the connection refused issue when using 2 different test machines" Watch "[RMI] How to et around the connection refused issue when using 2 different test machines" New topic
Author

[RMI] How to et around the connection refused issue when using 2 different test machines

Jean-Charles Wadja
Greenhorn

Joined: Aug 13, 2010
Posts: 5
Hi,

I running my application on 2 different machines (both of them ubuntu), and my client keeps crashing, saying that the connection was refused on 127.0.1.1.
I found that I could get it to work by changing the /etc/hosts of the server from

to with the server host name pointing directly to its local address.

This seems to be common problem, but I am still struggling to get around it. When creating the registry, I specifically gives the IP of the server on the local network, but this doesn't help. Is there a way I can force the client to get the correct address ?

This is how I create the connection for the client, the hostname being its IP address.

And the server creates the registry as follow :


Thanks for your help
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

Howdy, Jean-Charles. Welcome to JavaRanch!

Champ, first, I'd like to ask you: when you start your server, how you do that? More specifically, the "stub" variable, how do you create it? About your class that implements the interface that extends Remote, does it extend UnicastRemoteObject or not?

Other than that, I'd say that the code that binds the "stub" variable to the Registry may be wrong. Try changing it to:



Please do this change and let us know if it solves your problem.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

Are you actually setting one of the network cards to 127.0.1.1?


SCJA, OCPJP, OCMJD
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5266
    
  13

Hi Jean-Charles,

I guess you are working on a linux machine. And I remember reading about a similar issue last year, so used the search engine and found this thread. And you are correct: it is a common problem And the provided solution is simple: just make a change to your hosts file.

Hope it helps!
Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Jean-Charles Wadja
Greenhorn

Joined: Aug 13, 2010
Posts: 5
Hi,

Thanks for helping me.

Roberto Perillo wrote:
Champ, first, I'd like to ask you: when you start your server, how you do that? More specifically, the "stub" variable, how do you create it? About your class that implements the interface that extends Remote, does it extend UnicastRemoteObject or not?

I do not extend UnicastRemoteObject as I think this is confusing. Instead, I call the exportObject method with a cast

Roberto Perillo wrote:
Other than that, I'd say that the code that binds the "stub" variable to the Registry may be wrong.

It does work though. But I changed it to your suggestion, and it is actually easier to read. Thanks.
Roberto Perillo wrote:Please do this change and let us know if it solves your problem.
It did not I am afraid. Still stuck modifying my host file.
Chris Zaremba wrote:Are you actually setting one of the network cards to 127.0.1.1?
If I did, I didn't mean to. This was the default configuration on my box.
Roel De Nijs wrote:I guess you are working on a linux machine.
That's right. And I do agree that modifying the host file will get around the problem, but still, this is a modification the corrector will have to do manually; and as far as I understand the instructions, this is not acceptable. Do you think I can get away with it if I mention this in my documentation ? (Raf Szczypiorski does not say in the thread you gave if this was marked down on him).

Will test on a Windows server later tonight to see if I got the same issue there.

Thanks again for your help.

JC
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5266
    
  13

Jean-Charles Wadja wrote:(Raf Szczypiorski does not say in the thread you gave if this was marked down on him).

He passed the SCJD certification as he announced here (and he can't know if he lost points because of that, simply because you only get a pass or fail notification from Oracle, no score report anymore.
Jean-Charles Wadja
Greenhorn

Joined: Aug 13, 2010
Posts: 5
No score report anymore ?!? OK then.

I'll add it to my documentation unless I have an eureka moment before I submit my solution. I am now wrapping up everything and more and more questions are poping up, so I guess I'll be back here soon.

Thanks for your help.

JC
Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

Jean-Charles Wadja wrote:
Chris Zaremba wrote:Are you actually setting one of the network cards to 127.0.1.1?
If I did, I didn't mean to. This was the default configuration on my box.


From what I can understand from your post you have "serenity" is your server and on the client in the hosts file is the ip address of "serenity" is set to 127.0.1.1. Is this correct?

127.0.0.0/8 (127.0.0.1 - 127.255.255.254) are loopback addresses where the system can talk to itself using a network. It's useful for when you don't have a network setup but your application needs to use the network to work.

If you have a client and server on the network the easiest way if you're using static addresses and not DHCP (although not the best in terms of network administration) is just to add the remote computer name against it's actual ip address. You can get this by running ifconfig. This is essentially what you have done by changing it to the 192...... address.

I hope this makes sense.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

Howdy, Jean-Charles!

Will test on a Windows server later tonight to see if I got the same issue there.


Champ, did you have a chance to test your server on Windows? Were you able to solve your problem?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [RMI] How to et around the connection refused issue when using 2 different test machines