8 Replies Latest reply on Jun 3, 2013 6:33 AM by Darius Pėža

    Can't connect with JS Stomp client to HornetQ service

    Darius Pėža Newbie

      Hi,

       

      I have ruby on rails application, which run on torquebox. And I want use HornetQ functionality to push messages from rails application, to users browsers. I use HornetQ which is bundled with torquebox. By default bundled version with torquebox is with disabled stomp support. And I stuck with this.

      Here is my config https://gist.github.com/Dariusp/5684564 , I add netty acceptors stomp (port 61613) and stom_ws (port 61614). Both ports are open.

       

      native stomp is seems like is working (I test using telnet)

       

      telnet localhost 61613
      Trying 127.0.0.1...
      Connected to localhost.
      Escape character is '^]'.
      CONNECT
      login:
      passcode:
      ^@
      CONNECTED
      session:804089399

       

       

      But I can't connect with javascript stomp client (I use this https://github.com/jmesnil/stomp-websocket), I get 403 error forbidden.

       

      code which I use to connect

       

              client = Stomp.client( "ws://localhost:61614/stomp" );  //61613

              client.debug = function(str) {

                  $("#debug").append(str + "\n");

              };

              client.connect( '', '', function() {

                  client.debug("connected to Stomp");

                  client.subscribe('/topics/offers', function(message) {

                      // received a message!

                      client.debug("|"+message.body+"|");

                  } );

       

       

              }, function (err){

                  client.debug("error"+err);

       

              } );

        • 1. Re: Can't connect with JS Stomp client to HornetQ service
          Yong Hao Gao Master

          What version of HornetQ are you using? I'd suggest you try the stomp-websocket example first. The code in the example is very much similar to yours. After you get example up and running, it could be easier to find where is the problem by comparing the example with your own code.

           

          Howard

          • 2. Re: Can't connect with JS Stomp client to HornetQ service
            Darius Pėža Newbie

            My versions

             

            HornetQ......... 2.2.21.SNAPSHOT (HQ_2_2_21_final, 122)

            JBossAS......... 7.1.x.incremental.129

             

             

            I am not sure about which example you talk, but If about this https://github.com/jmesnil/stomp-websocket , then I wrote my code fallow this. It can't connect to my HornetQ setup, but it can connect to torquebox stomplets. I assume that JS code it's good, maybe some default login and password exists ?

             

            Little more info

            With Chrome (Version 25.0.1364.160 Ubuntu 12.04 (25.0.1364.160-0ubuntu0.12.04.1)) I get this error:

            WebSocket connection to 'ws://localhost:61614/stomp' failed: Error during WebSocket handshake: 'Sec-WebSocket-Accept' header is missing

             

            With Firefox (Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0) I get this error:

            "NetworkError: 403 Forbidden - http://localhost:61614/stomp"

            • 3. Re: Can't connect with JS Stomp client to HornetQ service
              Yong Hao Gao Master

              Make sure your security settings are correct (login/password) with AS 7. To find out if you need a default login/password, I suggest you first disable security on HornetQ (like <security-enabled>false</security-enabled) then run your script.

               

              Howard

              • 4. Re: Can't connect with JS Stomp client to HornetQ service
                Darius Pėža Newbie

                <security-enabled>false</security-enabled> is set, but it doesn't help. I still can't connect.

                • 5. Re: Can't connect with JS Stomp client to HornetQ service
                  Yong Hao Gao Master

                  That's strange. I've tried the later version of AS/HornetQ and it works for me. I believe there is something different in your server configuration.

                  I uploaded my test client. It's extracted from hornetq's jms/stomp-websockets example. Can you try it with your server? (Open the index.html with your Chrome browser).

                   

                  Howard

                  1 of 1 people found this helpful
                  • 6. Re: Can't connect with JS Stomp client to HornetQ service
                    Darius Pėža Newbie

                    With your chat demo, I got exacly some error like with my code.

                     

                    Can you share your hornetQ configuration?

                     

                    Here is my

                    <hornetq-server>

                                    <persistence-enabled>true</persistence-enabled>

                                    <security-enabled>false</security-enabled>

                                    <jmx-management-enabled>true</jmx-management-enabled>

                                    <journal-file-size>102400</journal-file-size>

                                    <journal-min-files>2</journal-min-files>

                     

                                    <connectors>

                                        <netty-connector name="netty" socket-binding="messaging"/>

                                        <netty-connector name="netty-throughput" socket-binding="messaging-throughput">

                                            <param key="batch-delay" value="50"/>

                                        </netty-connector>

                                <netty-connector name="stomp-ws" socket-binding="netty-stomp-ws" />

                                        <in-vm-connector name="in-vm" server-id="0"/>

                                    </connectors>

                     

                                    <acceptors>

                                        <netty-acceptor name="netty" socket-binding="messaging"/>

                                        <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">

                                            <param key="batch-delay" value="50"/>

                                            <param key="direct-deliver" value="false"/>

                                        </netty-acceptor>

                                <netty-acceptor name="stomp" socket-binding="netty-stomp">

                                <param key="protocol" value="stomp" />

                                </netty-acceptor>         

                                <netty-acceptor name="stomp-ws" socket-binding="netty-stomp-ws" >

                                <param key="protocol" value="stomp_ws"/>

                                </netty-acceptor>

                                        <in-vm-acceptor name="in-vm" server-id="0"/>

                                    </acceptors>

                     

                                    <security-settings>

                                        <security-setting match="#">

                                            <permission type="send" roles="guest"/>

                                            <permission type="consume" roles="guest"/>

                                            <permission type="createNonDurableQueue" roles="guest"/>

                                            <permission type="deleteNonDurableQueue" roles="guest"/>

                                        </security-setting>

                                    </security-settings>

                     

                                    <address-settings>

                                        <address-setting match="#">

                                            <dead-letter-address>jms.queue.DLQ</dead-letter-address>

                                            <expiry-address>jms.queue.ExpiryQueue</expiry-address>

                                            <redelivery-delay>0</redelivery-delay>

                                            <max-size-bytes>20971520</max-size-bytes>

                                            <address-full-policy>PAGE</address-full-policy>

                                            <message-counter-history-day-limit>10</message-counter-history-day-limit>

                                        </address-setting>

                                    </address-settings>

                     

                                    <jms-connection-factories>

                                        <connection-factory name="InVmConnectionFactory">

                                            <connectors>

                                                <connector-ref connector-name="in-vm"/>

                                            </connectors>

                                            <entries>

                                                <entry name="java:/ConnectionFactory"/>

                                            </entries>

                                            <consumer-window-size>1</consumer-window-size>

                                        </connection-factory>

                                        <connection-factory name="RemoteConnectionFactory">

                                            <connectors>

                                                <connector-ref connector-name="netty"/>

                                    <connector-ref connector-name="stomp-ws"/>

                                            </connectors>

                                            <entries>

                                                <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>

                                            </entries>

                                            <consumer-window-size>1</consumer-window-size>

                                        </connection-factory>

                     

                                        <pooled-connection-factory name="hornetq-ra">

                                            <transaction mode="xa"/>

                                            <connectors>

                                                <connector-ref connector-name="in-vm"/>

                                            </connectors>

                                            <entries>

                                                <entry name="java:/JmsXA"/>

                                            </entries>

                                        </pooled-connection-factory>

                                    </jms-connection-factories>

                                </hornetq-server>

                     

                    I just try standalone version 2.3.0.Final, And its works well. But I need somehow run bundled version with torquebox.

                    • 7. Re: Can't connect with JS Stomp client to HornetQ service
                      Yong Hao Gao Master

                      Here is mine. by the way what's the purpose for

                      <netty-connector name="stomp-ws" socket-binding="netty-stomp-ws" /> ?

                      • 8. Re: Can't connect with JS Stomp client to HornetQ service
                        Darius Pėža Newbie

                        Then was that moment, when I try anything...

                        Seems like I found issue, hornetQ version (2.2.21) bundled with torquebox its not working. I just downloaded standalone version 2.3 and its work, downloaded 2.2.14 (I didn't found 2.2.21 version) and its not work.