4 Replies Latest reply on Dec 2, 2003 9:52 AM by js1111

    Factory re-connect doesn't work. Connects only 30% of time

    js1111

      My PC client code tries to subscribe to a Topic with:
      tcf = (TopicConnectionFactory) jndiContext.lookup("ConnectionFactory");
      It fails to make a connection about 30% of the time. The error is javax.naming.ComminicationException : java.net.SocketTimeoutException: Receive timed out.

      My Solaris server code, which publishes to the Topic always works fine. (jboss is running on the Solaris box)

      If I stop my PC java program and restart it, it will connect 70% of the time. Once connected, everything else seems to work fine.

      Since I want a robust client, I decided to just detect this error, and re-try the connection code until it connects correctly. However that never works. I've tried to do the following:
      while(Try it 20 times)
      { pause 10 seconds
      jdniContext.close()
      setting all variables to null
      recreate jdniContext = new InitialContext(env)
      (all this works fine)
      tcf.lookup method above,
      (always fails if it didn't work the first time).
      }


      Any ideas?

      Thanks,

      Jeff


        • 1. Re: Factory re-connect doesn't work. Connects only 30% of ti

          Show the full stacktrace.

          You can also try enabling TRACE logging on the client
          for org.jnp to see what it is doing.

          Regards,
          Adrian

          • 2. Re: Factory re-connect doesn't work. Connects only 30% of ti
            js1111

            Arian,
            Thanks for the help. I setup log4 it gives me more trace information (below).

            A failed run shows..
            Connection refused
            ServiceUnavailableException
            SocketTimeoutException.
            javax... Receive Timed out.

            It almost seems that the socket is temporarily busy, which doesn't make much sense, since my client is the only thing running against it on my test.

            Again, this happens about 70% of the time. If I stop Java, and restart my client code, I can connect ok 30% of the time. Trying to reconnect without stop the code never seems to work.

            Thanks,

            Jeff


            ...
            tcf = (TopicConnectionFactory) jniContext.lookup("ConnectionFactory");
            .. (error)

            1943 [Thread-0] WARN org.jnp.interfaces.NamingContext - Failed to connect to myserver.mycomp.com:1099
            javax.naming.CommunicationException: Failed to connect to server myserver.mycomp.com:1099 [Root exception is javax.namin
            g.ServiceUnavailableException: Failed to connect to server myserver.mycomp.com:1099 [Root exception is java.net.ConnectE
            xception: Connection refused: connect]]
            at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:215)
            at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1181)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:514)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
            at javax.naming.InitialContext.lookup(Unknown Source)
            at smclient.SageManagerTopicSubscriber.initJMSConnection(SageManagerTopicSubscriber.java:142)
            at smclient.SageManagerTopicSubscriber.setupJMS(SageManagerTopicSubscriber.java:88)
            at smclient.SageManagerTopicSubscriber.run(SageManagerTopicSubscriber.java:72)
            Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server myserver.mycomp.com:1099 [Root exceptio
            n is java.net.ConnectException: Connection refused: connect]
            at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:190)
            ... 7 more
            Caused by: java.net.ConnectException: Connection refused: connect
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(Unknown Source)
            at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
            at java.net.PlainSocketImpl.connect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at java.net.Socket.connect(Unknown Source)
            at java.net.Socket.(Unknown Source)
            at java.net.Socket.(Unknown Source)
            at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:69)
            at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:62)
            at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:186)
            ... 7 more


            error ! JNDI context or lookup failed: javax.naming.CommunicationException: Receive timed out
            [Root exception is java.net.SocketTimeoutException: Receive timed out]

            • 3. Re: Factory re-connect doesn't work. Connects only 30% of ti

              Are you using Windows?
              Windows does little backlogging (by default).
              Too many connections at once cause it throw connection refused.

              http://www.mail-archive.com/jboss-user@lists.sourceforge.net/msg31572.html//www.mail-archive.com/jboss-user@lists.sourceforge.net/msg31572.html

              Regards,
              Adrian

              • 4. Re: Factory re-connect doesn't work. Connects only 30% of ti
                js1111

                Adrian,
                Thank you so much for helping !

                The problem is network related. I have 2 network cards on the Solaris box, with each IP mapped to the same hostname name. When my pc requests jnp://hostname:port, sometimes it is translated into jnp://ip1:port, and sometimes jnp://ip2:port. Unlike some other applications, Jboss only listens on one of those IP addresses. (netstat -an shows IP:port, rather the hostname:port). I can solve my problem by trying each one in turn.

                Thanks!

                Jeff