3 Replies Latest reply on Sep 21, 2010 9:32 AM by aevo

    Stomp - SocketException: Connection reset

    aevo

      Hi all,

       

      I'm using Perl and Stomp (cpan: Net-Stomp-0.38) to send messages to HornetQ (v. 2.1.2.Final). The perl code:

       

      #!/usr/bin/perl -w
      
      use Net::Stomp;
      
      
      my $stomp = Net::Stomp->new( { hostname => '...', port => '61613' } );
      $stomp->connect( { login => 'guest', passcode => 'guest' } );
      $stomp->send(
        { destination => '/queue/RbQueue',
          type => 'xml-msg',
          body => '<request>...</request>' } );
      $stomp->disconnect;
      

       

      Generally, it's working and the message is send to the queue correctly. But on the HornetQ server I'm getting an exception when I'm executing the script:

       

      [StompConnect Transport: tcp:///...:52840] 09:29:18,019 SEVERE [org.codehaus.stomp.jms.ProtocolConverter]  
      Caught: java.net.SocketException: Connection reset
       java.net.SocketException: Connection reset
               at java.net.SocketInputStream.read(SocketInputStream.java:168)
               at org.codehaus.stomp.tcp.TcpBufferedInputStream.fill(TcpBufferedInputStream.java:50)
               at org.codehaus.stomp.tcp.TcpBufferedInputStream.read(TcpBufferedInputStream.java:58)
               at java.io.DataInputStream.readByte(DataInputStream.java:248)
               at org.codehaus.stomp.StompMarshaller.readLine(StompMarshaller.java:189)
               at org.codehaus.stomp.StompMarshaller.unmarshal(StompMarshaller.java:94)
               at org.codehaus.stomp.tcp.TcpTransport.run(TcpTransport.java:130)
               at java.lang.Thread.run(Thread.java:619)
      

       

      What I'm doing wrong? Any ideas?

       

       

       

       

      HornetQ configuration:

       

      hornetq-configuration.xml:

       

      <acceptors>
            <acceptor name="netty">
               <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
               <param key="host"  value="${hornetq.remoting.netty.host:...}"/>
               <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>
            </acceptor>
      
            <!-- SVE: Added for Stomp -->
            <acceptor name="invm">
               <factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
            </acceptor>
            ...
      <address-settings>
            <!-- Main queue catch -->
            <address-setting match="jms.queue.RbQueue">
               <dead-letter-address>jms.queue.RbDeadLetterQueue</dead-letter-address>
               <redelivery-delay>3000</redelivery-delay>
               <redistribution-delay>500</redistribution-delay>
               <max-delivery-attempts>3</max-delivery-attempts>
               <max-size-bytes>-1</max-size-bytes>
               <page-size-bytes>10485760</page-size-bytes>
               <message-counter-history-day-limit>2</message-counter-history-day-limit>
               <address-full-policy>BLOCK</address-full-policy>
            </address-setting>
            ...
      

       

      hornetq-beans.xml:

       

         ...
         <!-- The JMS in-VM connection factory for StompConnect use -->
         <bean name="StompConnectionFactory" class="javax.jms.ConnectionFactory">
            <constructor factoryClass="org.hornetq.api.jms.HornetQJMSClient" 
                         factoryMethod="createConnectionFactory">
               <parameter class="org.hornetq.api.core.TransportConfiguration">
                 <bean class="org.hornetq.api.core.TransportConfiguration">
                    <constructor>
                       <parameter>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</parameter>
                    </constructor>
                 </bean>
               </parameter>
            </constructor>
         </bean>
      
         <!-- The StompConnect instance -->
         <bean name="StompConnect" class="org.codehaus.stomp.jms.StompConnect">
            <constructor>
               <parameter>
                  <inject bean="StompConnectionFactory"/>
               </parameter>
            </constructor>
            <install method="start"/>
         </bean>
         ...
      
        • 1. Re: Stomp - SocketException: Connection reset
          jmesnil

          Sascha Vetter wrote:

           

          Generally, it's working and the message is send to the queue correctly. But on the HornetQ server I'm getting an exception when I'm executing the script:

          [StompConnect Transport: tcp:///...:52840] 09:29:18,019 SEVERE [org.codehaus.stomp.jms.ProtocolConverter]  
          Caught: java.net.SocketException: Connection reset
           java.net.SocketException: Connection reset
                   at java.net.SocketInputStream.read(SocketInputStream.java:168)
                   at org.codehaus.stomp.tcp.TcpBufferedInputStream.fill(TcpBufferedInputStream.java:50)
                   at org.codehaus.stomp.tcp.TcpBufferedInputStream.read(TcpBufferedInputStream.java:58)
                   at java.io.DataInputStream.readByte(DataInputStream.java:248)
                   at org.codehaus.stomp.StompMarshaller.readLine(StompMarshaller.java:189)
                   at org.codehaus.stomp.StompMarshaller.unmarshal(StompMarshaller.java:94)
                   at org.codehaus.stomp.tcp.TcpTransport.run(TcpTransport.java:130)
                   at java.lang.Thread.run(Thread.java:619)
          

           

          What I'm doing wrong? Any ideas?

          This error occurs in the StompConnect layer which translates Stomp messages to JMS.

          Maybe you should look at this project to check if other users have seen similar issues: http://stomp.codehaus.org/StompConnect

           

          HornetQ now has native support for Stomp which does not require to use StompConnect: http://hornetq.sourceforge.net/docs/hornetq-2.1.2.Final/user-manual/en/html/interoperability.html#stomp.native

          You should give it a try, it is the preferred way to use Stomp with HornetQ.

          • 2. Re: Stomp - SocketException: Connection reset
            aevo

            The native support works fine! Thanks for the help! I added a comment to your blog entry about stomp (http://jmesnil.net/weblog/2010/01/14/using-stomp-with-hornetq/).

            • 3. Re: Stomp - SocketException: Connection reset
              aevo

              By the way, does anybody know the size limit for messages sent by stomp and a way to increase it? In my environment (perl: cpan:Net-Stomp-0.38) messages which are larger than circa 8 000 characters are not delivered to the queue.