12 Replies Latest reply on Oct 18, 2006 7:59 PM by andrepintorj

    org.jboss.remoting.CannotConnectException (ejb3)

    mhaerdi

      Hello
      When trying to connect to jboss (behind firewall) from a java client outside, i get a

      org.jboss.remoting.CannotConnectException: Can not get connection to server. Pr
      oblem establishing socket connection.
      at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(Soc
      ketClientInvoker.java:232)
      at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.jav
      a:117)
      at org.jboss.remoting.Client.invoke(Client.java:201)
      at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemot
      eInterceptor.java:39)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
      java:66)
      at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPr
      opagationInterceptor.java:44)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
      java:66)
      at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityC
      lientInterceptor.java:38)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
      java:66)
      at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalIntercept
      or.java:32)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
      java:66)
      at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteP
      roxy.java:82)
      at $Proxy1.getAllDomains(Unknown Source)
      at ch.own.fdomaintab.client.FDomaintabService.(FDomaintabService.j
      ava:26)
      at ch.own.fdomaintab.client.FDomaintabService.inst(FDomaintabService.jav
      a:45)
      at ch.own.immo.client.LiegenschaftTypPanel.initComponents(LiegenschaftTy
      pPanel.java:43)
      at ch.own.immo.client.LiegenschaftTypPanel.(LiegenschaftTypPanel.j
      ava:33)
      at ch.own.immo.client.LiegenschaftWizard.(LiegenschaftWizard.java:
      38)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
      orAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
      onstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
      at java.lang.Class.newInstance0(Class.java:350)
      at java.lang.Class.newInstance(Class.java:303)
      at ch.own.fclient.panels.FDesktop$2.run(FDesktop.java:233)
      at ch.own.fclient.thread.foxtrot.AbstractWorkerThread$2.run(AbstractWork
      erThread.java:49)
      at java.security.AccessController.doPrivileged(Native Method)
      at ch.own.fclient.thread.foxtrot.AbstractWorkerThread.runTask(AbstractWo
      rkerThread.java:45)
      at ch.own.fclient.thread.foxtrot.workers.DefaultWorkerThread.run(Default
      WorkerThread.java:153)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: java.net.ConnectException: Connection timed out: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
      at java.net.Socket.connect(Socket.java:507)
      at java.net.Socket.connect(Socket.java:457)
      at java.net.Socket.(Socket.java:365)
      at java.net.Socket.(Socket.java:178)
      at org.jboss.remoting.transport.socket.SocketClientInvoker.getConnection
      (SocketClientInvoker.java:450)
      at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(Soc
      ketClientInvoker.java:228)
      ... 29 more


      My configuration:
      jboss 4.0.2RC1
      ejb3 preview 4
      firewall ports forwarded to jboss:
      1098 1099 4444 4445 3528 (all TCP&UDP)

      I did not change any jboss config file
      I start jboss with run.bat -c all -Djava.rmi.server.hostname=<outer-ip-addr> -Djava.rmi.server.useLocalHostanme=false

      The client is behind a firewall too, but all ports are open in lan->wan direction

      Thanks in advance

        • 1. Re: org.jboss.remoting.CannotConnectException (ejb3)

          The port that ejb3 uses is defined by the org.jboss.remoting.transport.Connector configuration. In ejb3, looks like this is 3873. You can double check by looking for the jboss-service.xml in your ejb3 distro and seeing what it is set to within that.

          • 2. Re: org.jboss.remoting.CannotConnectException (ejb3)
            mhaerdi

            with port 3873 opened, i get still the same error... (after some minutes)

            the port is defined in jboss-service.xml in the deployed directory ejb3.deployer/META-INF but not in conf/jboss-service.xml

            maybe i have to replace the ip in "socket://0.0.0.0:3873" by the server ip?

            i don't have to forward ports in the firewall on the client side, do i?

            "tom.elrod@jboss.com" wrote:
            The port that ejb3 uses is defined by the org.jboss.remoting.transport.Connector configuration. In ejb3, looks like this is 3873. You can double check by looking for the jboss-service.xml in your ejb3 distro and seeing what it is set to within that.


            • 3. Re: org.jboss.remoting.CannotConnectException (ejb3)

              Since the ip is 0.0.0.0, the server will just bind to its local host and use that ip as the address it tells clients to connect to. This is probably something like 192.168.1.1. The client, which is outside the firewall, probably does not access the server machine via the previous ip, but via some external ip (i.e. 56.23.35.2). Since the server does not know explicitly what this ip is, it can not tell the client to use this ip. You can change the address that the client tried to connect to the server on by changing the configuration (see http://wiki.jboss.org/wiki/Wiki.jsp?page=Remoting_Transports_Configuration).

              • 4. Re: org.jboss.remoting.CannotConnectException (ejb3)
                mhaerdi

                still the same error... in the tcp/udp traffic on the client side i found at least one udp addressed to the server's internal address (192.168.x.x)

                according to http://wiki.jboss.org/wiki/Wiki.jsp?page=Remoting_Transports_Configuration, I changed the file jboss-service.xml in
                \jboss-4.0.2\server\all\deploy\ejb3.deployer\META-INF
                to:

                <?xml version="1.0" encoding="UTF-8"?>
                <server>
                 <mbean code="org.jboss.ejb3.EJB3Deployer" name="jboss.ejb3:service=EJB3Deployer">
                 <depends>jboss.aop:service=AspectDeployer</depends>
                 </mbean>
                 <mbean code="org.jboss.remoting.transport.Connector"
                 xmbean-dd="org/jboss/remoting/transport/Connector.xml"
                 name="jboss.remoting:type=Connector,transport=socket3873,handler=ejb3">
                 <depends>jboss.aop:service=AspectDeployer</depends>
                 <!--attribute name="InvokerLocator">socket://192.168.123.1:3873</attribute>
                 <attribute name="Configuration">
                 <handlers>
                 <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
                 </handlers>
                 </attribute-->
                 <attribute name="Configuration">
                 <config>
                 <invoker transport="socket">
                 <attribute name="numAcceptThreads">1</attribute>
                 <attribute name="maxPoolSize">303</attribute>
                 <attribute name="clientMaxPoolSize">304</attribute>
                 <attribute name="socketTimeout">10000</attribute>
                 <attribute name="serverBindAddress">192.168.123.1</attribute>
                 <attribute name="serverBindPort">3873</attribute>
                 <attribute name="clientConnectAddress">212.254.183.234</attribute>
                 <attribute name="clientConnectPort">3873</attribute>
                 <attribute name="enableTcpNoDelay" isParam="true">false</attribute>
                 <attribute name="backlog">200</attribute>
                 </invoker>
                 <handlers>
                 <!--handler subsystem="mock">org.jboss.remoting.transport.mock.MockServerInvocationHandler</handler-->
                 <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
                 </handlers>
                 </config>
                 </attribute>
                 </mbean>
                </server>


                192.168.123.1 is the internal address of the server in the lan
                212.254.183.234 is the external address of the server (firewall wan-ip)

                i still start jboss with
                run.bat -c all -Djava.rmi.server.hostname=212.254.183.234
                -Djava.rmi.server.useLocalHostname=false

                The client connects with
                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                java.naming.provider.url=jnp://212.254.183.234:1099

                what is wrong/missing?


                "tom.elrod@jboss.com" wrote:
                Since the ip is 0.0.0.0, the server will just bind to its local host and use that ip as the address it tells clients to connect to. This is probably something like 192.168.1.1. The client, which is outside the firewall, probably does not access the server machine via the previous ip, but via some external ip (i.e. 56.23.35.2). Since the server does not know explicitly what this ip is, it can not tell the client to use this ip. You can change the address that the client tried to connect to the server on by changing the configuration (see http://wiki.jboss.org/wiki/Wiki.jsp?page=Remoting_Transports_Configuration).



                • 5. Re: org.jboss.remoting.CannotConnectException (ejb3)
                  mhaerdi

                  up

                  • 6. Re: org.jboss.remoting.CannotConnectException (ejb3)

                    I have the same problem. In a local network everything runs ok, but when the server is behind a firewall, the client can not connect.

                    What files and configutrations do I have to change?

                    All ports are openned (80, 1099,8080,4444,1098,4445,8009,8083,8092,8093) in the firewall

                    Thanks for the help
                    Pepe

                    • 7. Re: org.jboss.remoting.CannotConnectException (ejb3)
                      mhaerdi

                      still waiting for help / solution

                      "jherrero" wrote:
                      I have the same problem. In a local network everything runs ok, but when the server is behind a firewall, the client can not connect.

                      What files and configutrations do I have to change?

                      All ports are openned (80, 1099,8080,4444,1098,4445,8009,8083,8092,8093) in the firewall

                      Thanks for the help
                      Pepe


                      • 8. Re: org.jboss.remoting.CannotConnectException (ejb3)

                        You will also need to add the following annotation to your bean:

                        @RemoteBinding(clientBindUrl="socket://[host]:[port]")
                        

                        So an example from the ejb3 tutorial would be:
                        ...
                        @Stateful
                        @RemoteBinding(clientBindUrl="socket://66.56.72.34:3873")
                        public class ShoppingCartBean implements ShoppingCart, Serializable
                        {
                        ...
                        

                        where the external address for my server is 66.56.72.34.

                        In a future release of ejb3, this should not be required and should pick up the proper locator url as specified in the server (via the jboss-service.xml). However, overriding the bind information for the client will always be allowed via the RemoteBinding annotation (if have a particular need for this).


                        • 9. Re: org.jboss.remoting.CannotConnectException (ejb3)
                          mhaerdi

                          it works!

                          thanks!

                          • 10. Re: org.jboss.remoting.CannotConnectException (ejb3)
                            bendis

                            Hi!

                            @RemoteBinding annotation solves this problem, but IMHO very badly. IP addresses, ports etc. should *not* be directly in the Java code of beans! What if I move some beans to JBoss behind firewall? What if I change the port number? I must edit and recompile *every* EJB.

                            Specifying the adrress using this annotation is like hard-coding JDBC URLs directly into Java code!

                            This information should be stored somewhere in the JBoss configuration... And it is - the clientConnectAddress and clientConnectPort attributes in ejb3.deployer/META-INF/jboss-service.xml (see the post above). But EJB3.0 silently ignores this information and uses hard-coded default socket://0.0.0.0:3873 - unless specified by @RemoteBinding. My opinion is that @RemoteBinding annotation should have no clientBindUrl attribute. Instead, there should be some attribute which would refer to some specific org.jboss.remoting.transport.Connector MBean configuration.

                            What is your opinion? I consider @RemoteBinding.clientBindUrl as a serious design flaw - should I file a bug?

                            Regards,
                            Bendis

                            • 11. Re: org.jboss.remoting.CannotConnectException (ejb3)

                              I have talked with Bill (ejb3 lead) via e-mail and we both agree that should be made to use the locator uri from the connector specified in the service xml if not defined via the annotation. Just forgot to open a jira issue at that point in time, but just did (EJBTHREE-204).

                              • 12. Re: org.jboss.remoting.CannotConnectException (ejb3)
                                andrepintorj

                                I have right now *exactly* the same problem... I'm trying to access a bean over a NAT, but I don't want to hard code the external IP on the beans since the IP is not static... So, I hope there is a solution soon. BTW, I would like to set the param "clientConnectAddress" as a URL and not an IP number since I want to use it with a dynamic IP number and a service like "no-ip"...