7 Replies Latest reply on Dec 9, 2015 8:27 AM by aelmalki

    unable to connect to HornetQServlet in JBoss 7

    martin.helwig

      I want to use HornetQServlet in jboss 7. I have configured the following in a clean jboss 7 installation:

       

      $JBOSS_HOME/standalone/configuration/standalone-preview.xml
      ...
      <connectors>
         <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
            <param key="batch-delay" value="50"/>
         </netty-connector>
      
         <in-vm-connector name="in-vm" server-id="0"/>
      
         <netty-connector name="netty-servlet" socket-binding="messaging">
            <param key="host" value="org.hornetq"/>
            <param key="port" value="8080"/>
            <param key="use-servlet" value="true"/>
            <param key="servlet-path" value="/messaging/HornetQServlet"/>
          </netty-connector>
      </connectors>
      
      <acceptors>
         <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
            <param key="batch-delay" value="50"/>
            <param key="direct-deliver" value="false"/>
         </netty-acceptor>
      
         <in-vm-acceptor name="in-vm" server-id="0"/>
      
         <netty-acceptor name="netty-invm" socket-binding="messaging">
            <param key="use-invm" value="true"/>
            <param key="host" value="org.hornetq"/>
         </netty-acceptor>
      </acceptors>
      ...
      

       

      I also deployed the servlet

       

      $JBOSS_HOME/standalone/deployments/messaging.war/WEB-INF/web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
              http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      
          <servlet>
              <servlet-name>HornetQServlet</servlet-name>
              <servlet-class>
                  org.jboss.netty.channel.socket.http.HttpTunnelingServlet</servlet-class>
              <init-param>
                  <param-name>endpoint</param-name>
                  <param-value>local:org.hornetq</param-value>
              </init-param>
              <load-on-startup>1</load-on-startup>
          </servlet>
          <servlet-mapping>
              <servlet-name>HornetQServlet</servlet-name>
              <url-pattern>/HornetQServlet</url-pattern>
          </servlet-mapping>
      
          <!-- Session timeout configuration -->
              <session-config>
                      <session-timeout>30</session-timeout>
              </session-config>
      
              <welcome-file-list>
                      <welcome-file>index.html</welcome-file>
              </welcome-file-list>
      </web-app>
      

       

       

      I try to connect from a remote machine with the following code:

       

      Map<String, Object> connectionParams = new HashMap<String, Object>();
      connectionParams.put("host", "myHostname");
      connectionParams.put("port", 8080);
      connectionParams.put("use-servlet", true);
      
      TransportConfiguration transportConfiguration = new TransportConfiguration(
              NettyConnectorFactory.class.getName(), connectionParams);
      
      ConnectionFactory connectionFactory = (ConnectionFactory)HornetQJMSClient.createConnectionFactoryWithoutHA(
              JMSFactoryType.CF, transportConfiguration);
      
      Connection connection = connectionFactory.createConnection();
      

       

      I can't connect and all I see is the following warning in jboss console

      14:11:13,918 WARNUNG [org.jboss.netty.channel.socket.http.HttpTunnelingServlet] Endpoint unavailable: connection refused: java.net.ConnectException: connection refused
              at org.jboss.netty.channel.local.LocalClientChannelSink.connect(LocalClientChannelSink.java:115) [netty-3.2.3.Final.jar:]
              at org.jboss.netty.channel.local.LocalClientChannelSink.eventSunk(LocalClientChannelSink.java:72) [netty-3.2.3.Final.jar:]
              at org.jboss.netty.channel.Channels.connect(Channels.java:541) [netty-3.2.3.Final.jar:]
              at org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:218) [netty-3.2.3.Final.jar:]
              at org.jboss.netty.channel.socket.http.HttpTunnelingServlet.service(HttpTunnelingServlet.java:150) [netty-3.2.3.Final.jar:]
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
              at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
              at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]
      

       

       

      What's wrong with my configuration?

        • 1. Re: unable to connect to HornetQServlet in JBoss 7
          georgr

          Hi Martin,

          did you manage to resolve the configuration issue?

          I've got the same problem.

          As I understand org.jboss.netty.channel.socket.http.HttpTunnelingServlet.service(HttpServletRequest, HttpServletResponse), the acceptor hasn't been created, yet.

          Thanks a lot,

          Georg

          • 2. Re: unable to connect to HornetQServlet in JBoss 7
            martin.helwig

            Hi Georg,

             

            no I didn't solve the problem. I also tried to configure hornetq to accept communication on a different port over http. This seems to work in local network, but if I use an apache webserver to proxy this requests, so that I only have one open port to the wide world, it also doesn't work.

             

             

            Martin

            • 3. Re: unable to connect to HornetQServlet in JBoss 7
              jmesnil

              Martin Helwig wrote:

               

              $JBOSS_HOME/standalone/configuration/standalone-preview.xml

              ...    <netty-connector name="netty-servlet" socket-binding="messaging">       <param key="host" value="org.hornetq"/>       <param key="port" value="8080"/>       <param key="use-servlet" value="true"/>       <param key="servlet-path" value="/messaging/HornetQServlet"/>     </netty-connector> </connectors>

              What's wrong with my configuration?

               

              You are telling your client to connect to the HTTP server at http://org.hornetq:8080/messaging/HornetQServlet/

               

              you need to give your server host instead of "org.hornetq"

              • 4. Re: unable to connect to HornetQServlet in JBoss 7
                martin.helwig

                I tried this with the same error... did you have a working configuration?

                • 5. Re: unable to connect to HornetQServlet in JBoss 7
                  georgr

                  Hi Jeff, Martin,

                  for my limited understanding of the matter, there are currently two "show stoppers" for using Servlet Transport on JBoss AS 7.1 with only HTTP ports open on AS side:

                  • The in-vm transport from HornetQServlet to JMS acceptor is not working, probably due to the fact that a netty LocalAddress is used by the HttpTunnelingServlet, which is required to use the same classloader on both side of communication.
                  • There is no HttpInvoker available to handle remote JNDI Lookups

                  We decided to work around by using HornetQ REST interface (http://docs.jboss.org/resteasy/hornetq-rest/1.0-beta-1/userguide/html_single/index.html#d0e49 ). There are a couple of REST examples in the HornetQ src distribution, plus I found this post helpful: https://community.jboss.org/message/714808

                  Servlet Transport would still be our preferred approch, since it allows using JMS on the client side.

                  Thanks a lot for clarification.

                  • 6. Re: unable to connect to HornetQServlet in JBoss 7
                    martin.helwig

                    Hi,

                     

                    what about http-enabled transport?

                    In my screnario I want to send and receive messages from all over the world with a client application. My JBoss is behind an apache proxy, so the only way is to communicate over http port 80.

                    On JBoss side I can configure a separate port with http-enabled parameter. My client in local network can connect to that port, but if I try to proxy the request via apache reverseproxy I get "... client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23) ..." in apache error log.

                    • 7. Re: unable to connect to HornetQServlet in JBoss 7
                      aelmalki

                      I think you also need to add a required Netty dependency like following:

                      MANIFEST.MF

                      Dependencies: org.jboss.netty

                      jboss-deployement-structure.xml

                      <jboss-deployment-structure>

                           <deployment>

                                <dependencies>

                                     <module name="org.jboss.netty" />

                                </dependencies>

                           </deployment>

                      </jboss-deployment-structure>

                      Hoping that it will help someone.