So here is my setup. I've got jboss 4.0.3SP1 running on linux bound to port 192.168.1.2. I've configured my router to forward all ports to this ip address and I've turned off my firewall temporarily. I have a JMS queue running which I am able to send an receive messages from on any computer in my network by specifying 192.168.1.2 as the jndi provider url. Now I'm trying to connect to this same queue over the internet from a remote box, and I'm unable to even create the Initial Context. I get this error.
java.rmi.ConnectException: Connection refused to host: 192.168.1.2; nested exception 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 org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
Now, what is interesting is that in the jndi properties file I've specified my WAN ip address as the jndi provider url, but in the error message I see the internal 192.168.1.2 address. So I guess it is forwarding correctly at least. Also if from the remote machine I do telnet [wanip] 1099 I get this:
1/Ã¢Â˜ÂºÃ¢Â†Â”Ã¢Â•Â L+Ã¢Â”ÂœÃƒÂ‡Ã¢Â˜Âºx `L!t
Connection to host lost.
Any ideas why I can't connect?
So I found the answer here:
I guess at some points, JBoss returns different addresses to the client which it then uses to make different connections. My setup was returning my internal 192.168.1.2 address, so these were not working. The solution was to change some configuration to return my WAN IP instead of my internal one. However, now I can't connect from any computer on my network. Anyone know how to configure JBoss so it is accessible both behind and outside a firewall?
you could try and put two network cards in the box (or ip alias) and get Jboss to listen on all interfaces via the -b 0.0.0.0 option
Thanks for the response.
So the current issue is this. If I connect to my queue remotely, it works. This is because I used the following configuration which tells jboss to send clients the WAN ip instead of the internal ip to use for connecting.
So now, when I connect from a machine inside the network, the connection starts, but the server is still telling the client to connect through the WAN ip, even though the client is on the internal network. When the client tries to do this, it eventually gets a connection reset by the server. So there are two ways I can see to fix this, but I don't know if either are possible.
1. Somehow specify the "java.rmi.server.hostname" per client. If the client is remote, it should connect through the internet. Otherwise it should connect throught he servers local IP.
2. When an internal client is trying to connect to the servers WAN IP, RMI chooses a random port for the communication. Since I don't have all ports forwarded to my server, this could be the issue. Can I specify a range of ports for RMI to work with?