6 Replies Latest reply: Jun 27, 2012 7:14 AM by John Burgess RSS

    Server behind the NAT firewall (again)

    Egidijus Vaisnora Newbie

      JBoss 5.0.1, EJB 3. Server is running on computer which doesn't have remote IP only local

       

      Got exception "Caused by: org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://10.198.138.148:3873/?]"

       

      Server is launched -Djava.rmi.server.hostname=<remote_ip> -Dremoting.bind_by_host=false

       

      Additionally I found, that I can and need to define property "clientConnectAddress=<remote_ip>" for jboss remoting.

      I added (uncommented line) into remoting-jboss-bens.xml, but it didn't work. Then I found that this connector is for EJB2 but for EJB3 is used ejb3-connectors-jboss-beans.xml . Then I added following lines to EJB3 connector

       

       

      <!-- Remoting Server Configuration -->
        <bean name="ServerConfiguration"
          class="org.jboss.remoting.ServerConfiguration">
          <property name="invocationHandlers">
            <map keyClass="java.lang.String" valueClass="java.lang.String">
              <entry>
                <key>AOP</key>
                <value>
                  org.jboss.aspects.remoting.AOPRemotingInvocationHandler
                </value>
              </entry>
            </map>
          </property>
          <property name="invokerLocatorParameters">
            <map keyClass="java.lang.String" valueClass="java.lang.String">
              <entry>
                <key>clientConnectAddress</key>
                <value>
                  <remote_ip>
                </value>
              </entry>
            </map>
          </property>
        </bean>
      Still not working...  I have bad feeling that I am adding clientConnectAddress in wrong way, but there are no sample on this.
      Please advice
        • 1. Re: Server behind the NAT firewall (again)
          Ron Sigal Master

          Hi Ejidijus,

           

          I don't see anything wrong with your configuration.

           

          * What do you mean by "Server is running on computer which doesn't have remote IP only local"?

           

          * Is 10.198.138.148 the value you associated with "clientConnectAddress" or your localhost address?

           

          -Ron


          • 2. Re: Server behind the NAT firewall (again)
            Egidijus Vaisnora Newbie

            "Server is running on computer which doesn't have remote IP only local"

            jboss server is running on computer which has only network configuraiton and it is only local IP. This computer is accessed via router which makes makes NAT'ing to this local IP

             

            Is 10.198.138.148 the value you associated with "clientConnectAddress" or your localhost address?

            it is local ip

             

            After debuging a while I found solution by entering serverBindAddress via URL parameter. I don't know it it is right configuration, but with this I got progress on issue:

             

            <value-factory bean="ServiceBindingManager"
                    method="getStringBinding">
                    <parameter>
                      jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3
                    </parameter>
                    <parameter>
                      <null />
                    </parameter>
                    <parameter>socket://remote_IP:${port}/?clientConnectAddress=remote_IP&amp;serverBindAddress=${jboss.bind.address}</parameter>
                    <parameter>
                      <null />
                    </parameter>
                    <parameter>3873</parameter>
                  </value-factory>

            • 3. Re: Server behind the NAT firewall (again)
              Egidijus Vaisnora Newbie

              Just information for other. My server was behind NAT router and it accepted connections from outside and from localhost. I have configured

              ejb3-connectors-jboss-beans.xml file following and it works:

               

              socket://multihome:${port}/?homes=${jboss.bind.address}&amp;connecthomes=localhost!<remote_IP>

              • 4. Re: Server behind the NAT firewall (again)
                natsuko Newbie

                I have a similar problem, and I am using JBoss AS6.  I believe the way of configuring ejb3-connectors-jboss-beans.xml is the right way for AS6 ? 

                [ Is that the only place to configure? ]

                And I finally found some syntax explanation in JBoss Remoting Guide (version 2.5.4.SP2), in section 5.4.1.2. Multihome servers.

                 

                This is my scenario:

                We have a physical Server A (internal IP: 192.168.2.187) within LAN, which connects to outside world via a modem/router.  We use Dynamic DNS service for outside to connect to our Server A.  So we have a web page that can be accessed this way:  http://xyz.dyndns-server.com:8080/myweb/

                For this Dyn DNS to work, the modem/router has to have forwarding address (xyz.dyndns-server.com => 192.168.2.187, with corresponding ports).  We open up ports 8080 and 1099.

                 

                This is the line that I have in ejb3-connectors-jboss-beans.xml :

                <parameter>socket://multihome:${port}/?homes=${jboss.bind.address}&amp;connecthomes=192.168.2.187!xyz.dyndns-server.com</parameter>

                 

                The problem is that, though my web application (html, jsp, servlet) is working fine, my Swing client somehow could not access the EJB3 (remote stateful session bean).  My Swing client, running in any other workstation/PC within the LAN, can access my EJB3 bean in Server A just fine.  I started the JBoss AS 6 with -b 0.0.0.0 option.

                 

                My Swing client uses the following for JNDI connection:

                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

                java.naming.provider.url=jnp://xyz.dyndns-server.com:1099

                 

                Can anyone help me out? What could be the root cause?  Do I miss anything here?   Thanks a lot.

                 

                ~Tew

                • 5. Re: Server behind the NAT firewall (again)
                  Ron Sigal Master

                  Hi Tew,

                   

                  Are you saying that your Swing client is having a problem accessing JDNI on the server, i.e., it is unable to download the EJB3 client proxy?  If that is the problem, then I can tell you that the JNDI implementation does not use Remoting, so the multihome trick will not work for JNDI.

                   

                  The JDNI implementation is part of the Application Server code base, so, if I have interpreted your problem correctly, I suggest that you post the question to the "JNDI and Naming" forum here:  http://community.jboss.org/en/jbossas/jndi.

                   

                  -Ron

                  • 6. Re: Server behind the NAT firewall (again)
                    John Burgess Newbie

                    You'll need to open ports 1098 (???more jndi of some sort) and 3873 (the actuall ejb3 bean) as well