5 Replies Latest reply on Apr 11, 2002 11:02 AM by Johann DUPUIS

    java.net.SocketException: Connection reset by peer: JVM_recv

    Henry Newbie

      Hi folks,

      I coded a MBean that is subscribed to a topic under JBoss-2.4.3_Tomcat-3.2.3.
      In the start method of the MBean I created a transacted session and a durable subscriber.

      public void start() {
      _factory = (TopicConnectionFactory)context.lookup (_factoryName);
      // parameters: User and Password for durable subscription - defined in file jbossmq-state.xml
      _connection = _factory.createTopicConnection("JNDISettings", "JNDISettings");
      // true indicates that the TopicSession is transactional
      _session = _connection.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE);
      _topic = (Topic)context.lookup(_topicName);
      //create a durable subscriber; parameter "JNDISettings" is an Id defined in jbossmq-state.xml
      _subscriber = _session.createDurableSubscriber(_topic, "JNDISettings");
      // set message listener
      _subscriber.setMessageListener(this);
      // start connection
      _connection.start();
      }

      The start method works out fine and does not throw any exceptions.

      When the client programm starts sending messages, JBoss throws the following exception:

      [OILClientIL] ConnectionReceiverOILClient is connecting to: 192.168.0.12:2238
      [OILServerILService] Connection failure (1).
      java.net.SocketException: Connection reset by peer: JVM_recv in socket input str
      eam read
      at java.net.SocketInputStream.socketRead(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:86)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:186)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:204)
      at java.io.ObjectInputStream.peekCode(ObjectInputStream.java:1549)
      at java.io.ObjectInputStream.refill(ObjectInputStream.java:1683)
      at java.io.ObjectInputStream.read(ObjectInputStream.java:1659)
      at java.io.ObjectInputStream.readByte(ObjectInputStream.java:1905)
      at org.jboss.mq.il.oil.OILServerILService.run(OILServerILService.java:19
      9)
      at java.lang.Thread.run(Thread.java:484)

      Does anyone have experience with that kind of exception ?

      kind regards Henry.

        • 1. Re: java.net.SocketException: Connection reset by peer: JVM_
          Eric Newbie

          I get the same error, but for a diffent problem.

          The Code:

          import org.apache.log4j.Category;
          import org.apache.log4j.PropertyConfigurator;

          public class MyLog4jTest
          {

          public static void main(String[] args)
          {
          Category cat = Category.getInstance(MyLog4jTest.class);
          PropertyConfigurator.configure("mylog4j.properties");

          cat.info("this is a test");
          }
          }

          The File:

          # Set root category priority to DEBUG and its only appender to A1.

          log4j.rootCategory=DEBUG, A1, J


          # A1 is set to be a ConsoleAppender.
          log4j.appender.A1=org.apache.log4j.ConsoleAppender

          # A1 uses PatternLayout.
          log4j.appender.A1.layout=org.apache.log4j.PatternLayout
          log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

          # J is set to be a JMSAppender
          log4j.appender.J=org.apache.log4j.net.JMSAppender

          log4j.appender.J.TopicConnectionFactoryBindingName=TopicConnectionFactory
          log4j.appender.J.TopicBindingName=topic/testTopic


          # J uses PatternLayout.
          log4j.appender.J.layout=org.apache.log4j.PatternLayout
          log4j.appender.J.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

          The Output:

          0 [main] DEBUG org.jboss.mq.referenceable.SpyConnectionFactoryObjectFactory
          - SpyConnectionFactoryObjectFactory->getObjectInstance()
          90 [main] DEBUG org.jboss.mq.Connection - Connection Initializing
          90 [main] DEBUG org.jboss.mq.Connection - Getting the serverIL
          90 [main] DEBUG org.jboss.mq.Connection - Authenticating
          100 [main] DEBUG org.jboss.mq.Connection - Starting the clientIL service
          150 [main] DEBUG org.jboss.mq.Connection - Connection establishment successful

          150 [main] DEBUG org.jboss.mq.Connection - Starting connection, ClientID=ID2
          210 [main] DEBUG org.jboss.mq.referenceable.SpyDestinationObjectFactory - SpyD
          estinationObjectFactory->getObjectInstance()
          140 [OILClientILService] DEBUG org.jboss.mq.il.oil.OILClientILService - Waitin
          g for the server to connect to me
          220 [main] INFO MyLog4jTest - this is a test

          The Console:

          [OILServerILService] Connection failure (1).
          java.net.SocketException: Connection reset by peer: JVM_recv in socket input str
          eam read
          at java.net.SocketInputStream.socketRead(Native Method)
          at java.net.SocketInputStream.read(Unknown Source)
          at java.io.BufferedInputStream.fill(Unknown Source)
          at java.io.BufferedInputStream.read(Unknown Source)
          at java.io.ObjectInputStream.peekCode(Unknown Source)
          at java.io.ObjectInputStream.refill(Unknown Source)
          at java.io.ObjectInputStream.read(Unknown Source)
          at java.io.ObjectInputStream.readByte(Unknown Source)
          at org.jboss.mq.il.oil.OILServerILService.run(OILServerILService.java:19
          9)
          at java.lang.Thread.run(Unknown Source)

          • 2. Re: java.net.SocketException: Connection reset by peer: JVM_
            Eric Newbie

            I get the same error, but for a diffent problem.

            The Code:

            import org.apache.log4j.Category;
            import org.apache.log4j.PropertyConfigurator;

            public class MyLog4jTest
            {

            public static void main(String[] args)
            {
            Category cat = Category.getInstance(MyLog4jTest.class);
            PropertyConfigurator.configure("mylog4j.properties");

            cat.info("this is a test");
            }
            }

            The File:

            # Set root category priority to DEBUG and its only appender to A1.

            log4j.rootCategory=DEBUG, A1, J


            # A1 is set to be a ConsoleAppender.
            log4j.appender.A1=org.apache.log4j.ConsoleAppender

            # A1 uses PatternLayout.
            log4j.appender.A1.layout=org.apache.log4j.PatternLayout
            log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

            # J is set to be a JMSAppender
            log4j.appender.J=org.apache.log4j.net.JMSAppender

            log4j.appender.J.TopicConnectionFactoryBindingName=TopicConnectionFactory
            log4j.appender.J.TopicBindingName=topic/testTopic


            # J uses PatternLayout.
            log4j.appender.J.layout=org.apache.log4j.PatternLayout
            log4j.appender.J.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

            The Output:

            0 [main] DEBUG org.jboss.mq.referenceable.SpyConnectionFactoryObjectFactory
            - SpyConnectionFactoryObjectFactory->getObjectInstance()
            90 [main] DEBUG org.jboss.mq.Connection - Connection Initializing
            90 [main] DEBUG org.jboss.mq.Connection - Getting the serverIL
            90 [main] DEBUG org.jboss.mq.Connection - Authenticating
            100 [main] DEBUG org.jboss.mq.Connection - Starting the clientIL service
            150 [main] DEBUG org.jboss.mq.Connection - Connection establishment successful

            150 [main] DEBUG org.jboss.mq.Connection - Starting connection, ClientID=ID2
            210 [main] DEBUG org.jboss.mq.referenceable.SpyDestinationObjectFactory - SpyD
            estinationObjectFactory->getObjectInstance()
            140 [OILClientILService] DEBUG org.jboss.mq.il.oil.OILClientILService - Waitin
            g for the server to connect to me
            220 [main] INFO MyLog4jTest - this is a test

            The Console:

            [OILServerILService] Connection failure (1).
            java.net.SocketException: Connection reset by peer: JVM_recv in socket input str
            eam read
            at java.net.SocketInputStream.socketRead(Native Method)
            at java.net.SocketInputStream.read(Unknown Source)
            at java.io.BufferedInputStream.fill(Unknown Source)
            at java.io.BufferedInputStream.read(Unknown Source)
            at java.io.ObjectInputStream.peekCode(Unknown Source)
            at java.io.ObjectInputStream.refill(Unknown Source)
            at java.io.ObjectInputStream.read(Unknown Source)
            at java.io.ObjectInputStream.readByte(Unknown Source)
            at org.jboss.mq.il.oil.OILServerILService.run(OILServerILService.java:19
            9)
            at java.lang.Thread.run(Unknown Source)

            • 3. Re: java.net.SocketException: Connection reset by peer: JVM_
              Eric Newbie

              Ok I think I figured out our problem. As the Error says, the connection is being reset by peer. I've done a little testing and found that if you don't close all connections and session properly before your program exits then the garbage colletion or some other mechanism closes the connections for you. And that is when you get the error, or that is when I got the error. I hope this helps!

              - Eric

              • 4. Re: java.net.SocketException: Connection reset by peer: JVM_
                Amy Newbie

                I got the same problem. How did you fix it? How can we close the connection properly?

                • 5. Re: java.net.SocketException: Connection reset by peer: JVM_
                  Johann DUPUIS Newbie

                  Hi,
                  I have exactly the same error using a variant of your attempt to get it work (see below).
                  I have added an explicit call to close function on jmsAppender, without a better result.
                  Thanks for help.

                  Johann


                  [...]
                  JMSAppender jmsAppender= new JMSAppender();
                  jmsAppender.setTopicBindingName("topic/testTopic");
                  jmsAppender.setTopicConnectionFactoryBindingName("TopicConnectionFactory");
                  jmsAppender.setLayout(new org.apache.log4j.PatternLayout("%-4r [%t] %-5p %c %x - %m%n"));
                  jmsAppender.setName("testingName");
                  jmsAppender.activateOptions();
                  catIntfBatch.addAppender(jmsAppender);

                  catIntfBatch.info("Entering application.");
                  catIntfBatch.fatal("Fatal ERROR.");
                  catIntfBatch.info("Exiting application.");
                  jmsAppender.close();
                  [...]

                  Here Is the server.log (jdk 1.4 + JBoss2.4.4_Tomcat4.0.1):

                  [16:54:06,546,OILServerILService] Connection failure (1).
                  java.net.SocketException: Connection reset by peer: Connection reset by peer
                  at java.net.SocketInputStream.socketRead0(Native Method)
                  at java.net.SocketInputStream.read(SocketInputStream.java:116)
                  at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
                  at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
                  at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2118)
                  at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2301)
                  at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2368)
                  at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2440)
                  at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2589)
                  at java.io.ObjectInputStream.readByte(ObjectInputStream.java:837)
                  at org.jboss.mq.il.oil.OILServerILService.run(OILServerILService.java:219)
                  at java.lang.Thread.run(Thread.java:536)