3 Replies Latest reply on Nov 27, 2008 12:08 PM by jlashmet

    connect over internet to jms queue


      Hi everyone,

      So here is my setup. I've got jboss 4.0.3SP1 running on linux bound to port 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 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:; 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 org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      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 address. So I guess it is forwarding correctly at least. Also if from the remote machine I do telnet [wanip] 1099 I get this:

      ↨°Tα☻xp3¼�†t"http://localhost.localdomain:8083/q~q~uq~♥┬¼�†sr org.jnp.server.Namin
      1/☺↔╠L+├Ç☺x `L!t

      Connection to host lost.

      Any ideas why I can't connect?

        • 1. Re: connect over internet to jms queue

          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 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?

          • 2. Re: connect over internet to jms queue

            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 option

            • 3. Re: connect over internet to jms queue

              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?