This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

RMI * * occurs when client on remote computer

Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a rmi client and server programs. When I run the server and the client on the same computer, everything is fine.
However, when I run the client program on other computer. The following exception occurs :
Connection refused to host:;
nested exception is: Operation timed out: connect
I use the default port (1099):
The server extends "UnicastRemoteObject"
In the server program --- Naming.rebind("//localhost/RmiServer", this);
In the client program --- obj = (RmiInterface) Naming.lookup("rmi://";);
where "" is the host name to find my server IP.
note: There will be no problem if both the server and client program run on the same computer.
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your problem *might* be with your Naming.rebind(). I had this problem as well with some recent work I was doing. The problem is that you are using localhost to define the ip address. Since localhost usually points to, your naming service stores this:
When you go to look for it from the same machine it finds it fine since points back to itself, but when you try to find it from somewhere else, your Naming.lookup is looking for something like this:
And the request gets to your machine, and to your RMIRegistry, but you have your server bound to:
which doesn't match
so you get some kind of connection denied error.
The solution to this was to to either hard code your true ip address, or discover it in some way. There may be an easier way than this, but here is what I did.
As you can see, I actually put it in the registry twice. once with the localhost ip and once with the realworld IP. That let me contact it both locally and remotely.
I am running my server side under linux, and that "localtb4ip" I was able to define in my local dns to the specific real world ip. You could probably hard code into the rebind if that was a permanent ip. My way is a bit disjointed, but it works.
Hope this helps,
[ May 27, 2003: Message edited by: Chris Shepherd ]
Vince Hon
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for you explantion, Chris.
I have tried to hardcode the and in the program:
i.e. In the Server
Naming:rebind("//", this);
But the same problem occurs,
However, when I use:
"java RmiServer"
where "RmiServer" is the class name of my server program
It works !! But it will not works if "java -Djava.rmi.server.hostname= RmiServer"
I think this matches what you have mentioned before.
Although I have solved the problem, but I still don't know the root of the problem and the meaning of the -Djava.rmi.server.hostname=......
Anyway, thanks u again
    Bookmark Topic Watch Topic
  • New Topic