RMI+NAT+FIREWALL

Hi Friends,

We are facing a problem when running our server behind a firewall.

The Client throws BindException.

When reviewed the forum, came to know that certain measures are to be done while running as such...

And i'm looking for one such sample code to test...I developed a sample code & the server throws AccessDeniedException...

I noticed that RMI+NAT+firewall is possible(saw in the post :http://forum.java.sun.com/thread.jspa?threadID=289869&messageID=1242288)

So java guru's help me in this issue...?

Tanx in advance

[583 byte] By [blackpanthersa] at [2007-11-27 3:05:42]
# 1
1. do you have a securityManager ?2. do you control the ports used by RMI ?3. do you redefine the HostName of the registry ?
DarkTwina at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 2
BindException means that you're trying to bind the client socket to a specific local IP address and port. You shouldn't need to do that: let the system decide.
ejpa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 3

Hi,

Let me tell u the actual problem..

Our RMIserver runs in a local machine connected to a server which is behind a firewall with an IP add say 59.92.88.150 with NAT configuration...My n/w admin has done port forwarding to the port on which i'm running RMI server.

Now when i try to communicate my client to the Server(not the RMIServer directly, the other one) from a public Ip say 219.64.55.125, i get a bind Exception & the full trace goes like this....

java.rmi.ConnectException: Connection refused to host: 59.92.88.150; nested exce

ption is:

java.net.ConnectException: Connection refused: connect

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)

at sun.rmi.server.UnicastRef.newCall(Unknown Source)

at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)

Kindly help me in this issue.

blackpanthersa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 4
Sorry for the Last post...Jus now i noticed that its not a bind Exception & its a connectionException.ejp tell me a possible way to solve this firewall+NAT configuration problem
blackpanthersa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 5

Now when i run my client code like the following,

java -Djava.rmi.server.hostname=59.92.88.150 -jar GameHawker.jar

I'm getting an NotBoundException & th trace is as follows:

java.rmi.NotBoundException: rmi://59.92.88.150:1090/GTSendAndReceive

at sun.rmi.registry.RegistryImpl.lookup(Unknown Source)

at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)

at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)

at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)

at sun.rmi.transport.Transport$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Unknown Source)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour

ce)

at java.lang.Thread.run(Unknown Source)

at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow

n Source)

at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)

at sun.rmi.server.UnicastRef.invoke(Unknown Source)

at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)

at com.eaglelot.gamehawker.login.GHTerminalLogin.validateTerminal(GHTerm

inalLogin.java:190)

blackpanthersa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 6

> java.rmi.NotBoundException: rmi://59.92.88.150:1090/GTSendAndReceive

Seems fairly clear. That name isn't bound in that registry. The RMI server isn't running, or it hasn't bound itself correctly. The connect exception before that mean that that registry wasn't even running.

BTW you don't need to set java.rmi.server.hostname in a client, unless it exports callbacks.

ejpa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 7

Hi,

But as i told u My RMI server is running perfectly.But in a local network...My client is connected to a public network, when started should connect my NAT configured Firewall & should be diverted to that spl IP, ( using port forwarding) i.e)to my RMIserver ...

I'm using callbacks in my application too...

blackpanthersa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 8
Your RMI server may be running perfectly but it doesn't seem to have bound itself with the name the client is looking for in the Registry the client is looking at.
ejpa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 9

Jus visualize this.....

My server is running perfect with Registry......

RMI Server(ip:192.168.0.111)--N/W Server(59.92.88.150)

|

Firewall(NAT:) 1090 is diverted to local IP 111

|

|

Client Machine(IP is :219.64.119.71)

Now when my client connects to RMI server it goes like this,

1)Link goes to firewall & not to server

2)Firewall forwards to the local IP i.e)192.168.0.111

3)Link s established

Is dis correct...?

I'm assuming as mentioned above & posting my questions...

The same appln when connected in a local n/w s running fine

blackpanthersa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 10

That all seems to be working as you have definitely connected to a Registry. The question at the moment is, is the server binding itself to rmi://59.92.88.150:1090/GTSendAndReceive ?

The next question once we've got that far is whether the server is also exporting itself on port 1090 or whether you have to forward another port?

But let's solve one thing at a time.

ejpa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 11
Hi,The server is binding object on rmi://192.168.0.111:1090/GTSendAndReceive & is exporting on PORT 1090.I couldn't figure out where's the problem...Did u get any idea about wats going wrong...?Thanks for ur reply
blackpanthersa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 12

Can you get the server to call Naming.list("rmi://59.92.88.150:1090") immediately after it binds, and print out the results?

Can I also make an important suggestion. Instead of typing GTSendAndReceive everywhere, use the name of the remote interface class, e.g. MyRemoteInterface.class.getName(), as the bind name to ensure they are the same throughout the system. It also gives you package-qualification of the name, which helps with uniqueness.

ejpa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 13

I changed my look up as suggested <InterfaceName.class.getName()> and listed out the bound remote object in server after its bound...

The server lists bound objects correctly as

rmi://59.92.88.150:1090/<full interface path>...

When i tried running my client i get the following trace ....

C:\TEST_EAGLELOT\MAY-07-2007\Version 1.0.2.6>java -jar GameHawker.jar

IsPrinter Initialized in java:0

java.net.ConnectException: Connection timed out: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(Unknown Source)

at java.net.PlainSocketImpl.connectToAddress(Unknown Source)

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknow

n Source)

at com.eaglelot.global.RMISSLClientSocketFactory.createSocket(RMISSLClie

ntSocketFactory.java:72)

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)

at sun.rmi.server.UnicastRef.newCall(Unknown Source)

at sun.rmi.transport.DGCImpl_Stub.dirty(Unknown Source)

at sun.rmi.transport.DGCClient$EndpointEntry.makeDirtyCall(Unknown Sourc

e)

at sun.rmi.transport.DGCClient$EndpointEntry.registerRefs(Unknown Source

)

at sun.rmi.transport.DGCClient.registerRefs(Unknown Source)

at sun.rmi.transport.ConnectionInputStream.registerRefs(Unknown Source)

at sun.rmi.transport.StreamRemoteCall.releaseInputStream(Unknown Source)

at sun.rmi.transport.StreamRemoteCall.done(Unknown Source)

at sun.rmi.server.UnicastRef.done(Unknown Source)

at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)

at com.eaglelot.gamehawker.login.GHTerminalLogin.validateTerminal(GHTerm

inalLogin.java:191)

at com.eaglelot.gamehawker.login.PnlUserLogin.appendChar(PnlUserLogin.ja

va:180)

at com.eaglelot.gamehawker.login.PnlUserLogin.actionPerformed(PnlUserLog

in.java:122)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow

n Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour

ce)

at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Sending Terminal Details.......

java.net.ConnectException: Connection timed out: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(Unknown Source)

at java.net.PlainSocketImpl.connectToAddress(Unknown Source)

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknow

n Source)

at com.eaglelot.global.RMISSLClientSocketFactory.createSocket(RMISSLClie

ntSocketFactory.java:72)

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)

at sun.rmi.server.UnicastRef.invoke(Unknown Source)

at com.eaglelot.gametransis.GTSendAndReceiveImpl_Stub.terminalAuthentica

te(Unknown Source)

at com.eaglelot.gamehawker.login.GHTerminalLogin.validateTerminal(GHTerm

inalLogin.java:199)

at com.eaglelot.gamehawker.login.PnlUserLogin.appendChar(PnlUserLogin.ja

va:180)

at com.eaglelot.gamehawker.login.PnlUserLogin.actionPerformed(PnlUserLog

in.java:122)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow

n Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour

ce)

at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

java.net.ConnectException: Connection timed out: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(Unknown Source)

at java.net.PlainSocketImpl.connectToAddress(Unknown Source)

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknow

n Source)

at com.eaglelot.global.RMISSLClientSocketFactory.createSocket(RMISSLClie

ntSocketFactory.java:72)

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)

at sun.rmi.server.UnicastRef.newCall(Unknown Source)

at sun.rmi.transport.DGCImpl_Stub.dirty(Unknown Source)

at sun.rmi.transport.DGCClient$EndpointEntry.makeDirtyCall(Unknown Sourc

e)

at sun.rmi.transport.DGCClient$EndpointEntry.access$1600(Unknown Source)

at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(Unknow

n Source)

at java.lang.Thread.run(Unknown Source)

java.rmi.ConnectException: Connection refused to host: 192.168.0.123; nested exc

eption is:

java.net.ConnectException: Connection timed out: connect

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)

at sun.rmi.server.UnicastRef.invoke(Unknown Source)

at com.eaglelot.gametransis.GTSendAndReceiveImpl_Stub.terminalAuthentica

te(Unknown Source)

at com.eaglelot.gamehawker.login.GHTerminalLogin.validateTerminal(GHTerm

inalLogin.java:199)

at com.eaglelot.gamehawker.login.PnlUserLogin.appendChar(PnlUserLogin.ja

va:180)

at com.eaglelot.gamehawker.login.PnlUserLogin.actionPerformed(PnlUserLog

in.java:122)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow

n Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour

ce)

at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.net.ConnectException: Connection timed out: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(Unknown Source)

at java.net.PlainSocketImpl.connectToAddress(Unknown Source)

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknow

n Source)

at com.eaglelot.global.RMISSLClientSocketFactory.createSocket(RMISSLClie

ntSocketFactory.java:79)

... 32 more

May 7, 2007 11:06:25 AM com.eaglelot.gamehawker.MainWindow LogSevereEvents

SEVERE: GHTerminalLogin, ValidateTerminal() ! -- java.rmi.ConnectException: Con

nection refused to host: 192.168.0.123; nested exception is:

java.net.ConnectException: Connection timed out: connect

java.net.ConnectException: Connection timed out: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(Unknown Source)

at java.net.PlainSocketImpl.connectToAddress(Unknown Source)

at java.net.PlainSocketImpl.connect(Unknown Source)

at java.net.Socket.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknow

n Source)

at com.eaglelot.global.RMISSLClientSocketFactory.createSocket(RMISSLClie

ntSocketFactory.java:72)

at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)

at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)

at sun.rmi.server.UnicastRef.newCall(Unknown Source)

at sun.rmi.transport.DGCImpl_Stub.dirty(Unknown Source)

at sun.rmi.transport.DGCClient$EndpointEntry.makeDirtyCall(Unknown Sourc

e)

at sun.rmi.transport.DGCClient$EndpointEntry.access$1600(Unknown Source)

at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(Unknow

n Source)

at java.lang.Thread.run(Unknown Source)

can any one suggest me y do i get a connection timed out Exception...

Is anything wrong with my Port forwarding stuffs....

I'm having doubt because ,i get a connectionException at last mentioning java.rmi.ConnectException: Connection refused to host: 192.168.0.123; nested exception is:

java.net.ConnectException: Connection timed out: connect

Help me Friends

blackpanthersa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 14
Hi,I am wonder if you solve your problem. I have exactly same same problem as yours. Hope to get helps. Thanks.
hchen_usa at 2007-7-12 3:51:30 > top of Java-index,Core,Core APIs...
# 15
i had this problem a while ago, here is a hackish solution which i used: http://www.cssassociates.com/rmifirewall.html
mkoryaka at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 16
Thanks for your nice help!
hchen_usa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 17

Hi,

I downloaded classes from http://www.cssassociates.com/rmifirewall.html and used their test example to run on our server machine and client. It still can't solve problem I have. On server side, program, it looks like that server can't bind (outside IP) and show s"connection refused to host". But it can be binded when I use inside IP). Anyway, client has exception "java.net.UnknownHostException" when server binds both IP.

Do you have any idea about this? Thanks.

hchen_usa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 18
See java.rmi.server.hostname in the RMI documentation. It needs to be set at the server JVM to the 'public' address of the host so that stubs exported from that JVM will contain an IP address accessible outside the host's enclave.
ejpa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 19

We have an inside IP address on server machine (eg. 190.99.190) and out side client use another public address (eg. 110.11.110) to access server machines. I have a program to call java 'socket' class and no problem to get connection on this server machines but RMI not. What's problem do you think? Thanks.

hchen_usa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 20
What I think is what I said in reply #18, which you need to act on.
ejpa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 21
Thanks for your quick reply. I got confuse about #18 action. Should I set server host IP address to public via Java RMI program or via system administrator to set up? And, how to set up if by java RMI server? Thanks for your time and nice help in advance
hchen_usa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 22
There are two ways:java -Djava.rmi.server.hostname=xxx mypackage.myserver [args]at the command line, orSystem.setProperty("java.rmi.server.hostname", "xxx");in the code.
ejpa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 23

Thanks,

I did it before and used number one way to set up host as out side public address (eg. 110.11.110). But it caused that server side RMI program sticked on line "Naming.binding("//"+hostname+":1099//HelloServer", helloServer");

Rest of code in server side RMI program couldn't be executed. Certainly, Client side program complained connection refused or NotBoundException

hchen_usa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 24

Naming.bind("//"+hostname+":1099/HelloServer", helloServer);

That needs to be

Naming.bind("//localhost:1099/HelloServer", helloServer);

There's no point in specifying any other hostname to Naming.bind, Naming.rebind, or Naming.unbind, and it's just a frequent source of error.

ejpa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 25
I did use localhost on server side program. It can binding on server side (inside host IP address) but client (outside public IP address ) program couldn't access this. It complained unknown host exception.
hchen_usa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 26
The hostname or IP the client uses in the Naming.lookup or Naming.list call has to be the public IP address of the firewall, not the internal hostname/address.
ejpa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 27
Thanks for your reply. As I post several previous messages, My server program would not bind if I use same public IP address as client's.
hchen_usa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 28
In reply #24 I said that the server should use 'localhost' when binding.In reply #26 I said that the client has to use the public IP address when doing lookup.Nowhere did I say the server should 'use same public IP address as client's'. You made that up.
ejpa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 29
Sorry to misunderstand you. But program didn't work whatever I use either localor public of two IP address on server side and client side (public).
hchen_usa at 2007-7-21 20:40:37 > top of Java-index,Core,Core APIs...
# 30

OK let's lay it out in a logical sequence.

1. If the client is getting UnknownHostException during Naming.lookup it means the Naming.lookup string is wrong (not the public address). Get this working first, at least to the point where it throws a Registry exception rather than a connection or host exception.

2. Now export the server and bind it to its local registry via 'localhost'. At this point the client's lookup should succeed completely.

3. If the client now gets UnknownHostException when executing a remote method after Naming.lookup works, it means the java.rmi.server.hostname at the server is wrong or not set to the public address.

4. If the client gets a ConnectException or a connection refused condition at either of those points after fixing the above it means the ports aren't forwarded correctly.

In both cases the correct port has to be forwarded from the public IP address device to the private device. In the case of the Registry that is 1099 by default. In the case of your remote object, it's the port it was exported on, which can also be 1099 if the Registry is in the same JVM.

5. Internal clients will be expected to connect to the RMI server(s) via the public IP address. They don't have to do that in the case of the Registry, they can use the internal IP address for lookups, but the result is still a stub with the external IP address embedded in it, if the steps above are working correctly. This is a constraint which is placed on the network toplogy by Sun RMI.

ejpa at 2007-7-21 20:40:42 > top of Java-index,Core,Core APIs...
# 31
Thanks for your nice help. I am working on it
hchen_usa at 2007-7-21 20:40:42 > top of Java-index,Core,Core APIs...