7 Replies Latest reply: Aug 17, 2008 2:07 PM by Jim Brownfield RSS

UnknownHostException after successful connection to port 109

Felix Mayer Newbie

I am trying to connect to a JBoss instance on a computer which is not in DNS. When I try to look up an EJB, the initial socket on :1099 connects, but then it looks like JBoss returns <host name>:1098 and the client tries to connect to that. This results in an UnknownHostException because the host name is not in DNS. One possible solution would be to add the host name to the local HOSTS file on the client, but I am looking for a solution that doesn't require me to go to every client. Can I somehow tell JBoss to return the IP address instead of the host name?

  • 1. Re: UnknownHostException after successful connection to port
    Kazuhisa Ichikawa Newbie

    You're probably using '-b hostname' option (or the equivalent long version '--host=hostname' option) when you start JBoss run.sh/run.bat.

    If that is the case, replace the hostname portion with the IP address.

    Alternatively, removing the -b (or --host) option will have the same effect, but if your JBoss is running on a multi-homed host, then this has a side effect of allowing connections on all IP addresses).

  • 2. Re: UnknownHostException after successful connection to port
    Chris Britton Newbie

    In 4.0 I did not specify a bind address and jboss returned an IP address in the Naming object. In 4.2, I specify a bind address of "-b 0.0.0.0" and jboss returns the configured hostname. This breaks the caller because the caller system is not running DNS.

    Shouldn't specifying "-b 0.0.0.0" in 4.2 be the same as not specifying a bind address in 4.0? Is there any way to bind to all interfaces in 4.2 and persuade it to return an IP address instead of a hostname in the Naming object?

    Thanks.

  • 3. Re: UnknownHostException after successful connection to port
    Kazuhisa Ichikawa Newbie

     

    Is there any way to bind to all interfaces in 4.2 and persuade it to return an IP address instead of a hostname in the Naming object?


    The easiest way to do this is to use system property 'java.rmi.server.hostname'.

    For example, on windows:

    SET JAVA_OPTS=-Djava.rmi.server.hostname=xx.xx.xx.xx
    run.bat -b 0.0.0.0


    Please note that this will change the rmi server codebase throughout your jboss server.

    If you don't like that, and want to have the change to take effect in JBoss naming service only, then do the following:

    1) open your server's 'conf/jboss-service.xml' file.
    2) locate the 'jboss:service=Naming' mbean.
    3) set the following 2 attributes.

    <attribute name="RmiBindAddress">xx.xx.xx.xx</attribute>
    <attribute name="ClientSocketFactory">org.jboss.net.sockets.DefaultClientSocketFactory</attribute>
    


    4) restart your jboss server with -b 0.0.0.0 option

  • 4. Re: UnknownHostException after successful connection to port
    Alexandre CUVILLIER Newbie

    I had the same problem and solve it with the previous messages.

    I have installed an EJB on jboss 4.2.2.


    But now I have an other errors

    2008-04-21 17:10:13 DEBUG [SecurityAssociation/:143] Using ThreadLocal: false
    2008-04-21 17:10:13 DEBUG [MicroSocketClientInvoker/:243] SocketClientInvoker[18b3364, socket://127.0.0.1:3873] constructed
    2008-04-21 17:10:13 DEBUG [MicroRemoteClientInvoker/:240] SocketClientInvoker[18b3364, socket://127.0.0.1:3873] connecting
    2008-04-21 17:10:13 DEBUG [MicroRemoteClientInvoker/:245] SocketClientInvoker[18b3364, socket://127.0.0.1:3873] connected
    2008-04-21 17:10:14 DEBUG [MicroSocketClientInvoker/:820] SocketClientInvoker[18b3364, socket://127.0.0.1:3873] got Exception java.net.ConnectException: Connection refused: connect, creation attempt took 984 ms
    2008-04-21 17:10:15 DEBUG [MicroSocketClientInvoker/:820] SocketClientInvoker[18b3364, socket://127.0.0.1:3873] got Exception java.net.ConnectException: Connection refused: connect, creation attempt took 1000 ms
    2008-04-21 17:10:16 DEBUG [MicroSocketClientInvoker/:820] SocketClientInvoker[18b3364, socket://127.0.0.1:3873] got Exception java.net.ConnectException: Connection refused: connect, creation attempt took 1000 ms
    2008-04-21 17:10:17 DEBUG [MicroSocketClientInvoker/:820] SocketClientInvoker[18b3364, socket://127.0.0.1:3873] got Exception java.net.ConnectException: Connection refused: connect, creation attempt took 1000 ms
    2008-04-21 17:10:18 DEBUG [MicroSocketClientInvoker/:820] SocketClientInvoker[18b3364, socket://127.0.0.1:3873] got Exception java.net.ConnectException: Connection refused: connect, creation attempt took 1000 ms
    2008-04-21 17:10:19 DEBUG [MicroSocketClientInvoker/:820] SocketClientInvoker[18b3364, socket://127.0.0.1:3873] got Exception java.net.ConnectException: Connection refused: connect, creation attempt took 1015 ms


    I don't know what to do to allow the client to connect to the EJB.

    Any ideas ?

  • 5. Re: UnknownHostException after successful connection to port
    Kazuhisa Ichikawa Newbie

    Which OS do you use?

    The ejb3 connector component of JBoss seems to have a bug of ignoring the '-b 0.0.0.0' option. Instead of '0.0.0.0', it tries to choose one (maybe the primary one?) from the IP addresses bound to the machine's network interfaces. And if it cannot find any valid IP address, it uses 127.0.0.1 (and its default port 3873).

    That said, if you are running the JBoss server on Windows, you need to make sure that the machine is connected to the network and has an IP address BEFORE you start JBoss server (As far as I know, Windows by default remove IP address from the network interface when it is not connected to the network).

    Otherwise, you are likely to get the error in the following scenario.

    1) You start JBoss server with '-b 0.0.0.0' option when the Windows machine is not connected to the network and does not have an IP address other than 127.0.0.1.
    2) The EJB3 connector component chooses '127.0.0.1' and listens at '127.0.0.1:3873'.
    3) Then you connect the Windows machine to the network to test EJB3 remote client. Now the machine gets an IP address, which is too late for the JBoss EJB3 component.
    4) Your EJB3 remote client receives from the server '127.0.0.1:3873' as an entry point, to which it tries to connect. But, since there is no JBoss server running at 127.0.0.1 (the localhost for the client), you get the error which you described in your post.

    Hope this helps.

  • 6. Re: UnknownHostException after successful connection to port
    Kazuhisa Ichikawa Newbie

     

    The ejb3 connector component of JBoss seems to have a bug of ignoring the '-b 0.0.0.0' option. Instead of '0.0.0.0', it tries to choose one (maybe the primary one?) from the IP addresses bound to the machine's network interfaces. And if it cannot find any valid IP address, it uses 127.0.0.1 (and its default port 3873).


    Just FYI, I found this in JIRA.

    http://jira.jboss.org/jira/browse/EJBTHREE-1191

  • 7. Re: UnknownHostException after successful connection to port
    Jim Brownfield Newbie

    For future browsers of this thread, the solution seems to be in this thread . Setting the remoting.bind_by_host property to false causes JBoss remoting to use the IP address. More information here