5 Replies Latest reply on Jan 27, 2015 10:13 AM by markusschwarz

    JMS (topic) from client working with HTTP but not correctly with HTTPS

    markusschwarz

      Hi,

      we are using a JMS topic on client side (only consumer) and it works very good with HTTP. If using HTTPS in the provider URL it also works very well.

      But if the HTTP port is blocked by firewall, there are exceptions on client side.

       

      The way we open the JMS connection using HTTP port is:

      Properties env = new Properties();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
      env.put(Context.PROVIDER_URL, "http-remoting://myserver:8080");
      env.put(Context.SECURITY_PRINCIPAL, "user");
      env.put(Context.SECURITY_CREDENTIALS, "password");
      
      
      InitialContext iniCtx = new InitialContext(env);
      ConnectionFactory connectionFactory = (ConnectionFactory) iniCtx.lookup("jms/RemoteConnectionFactory");
      Destination destination = (Destination) iniCtx.lookup("jms/topic/MyTopic");
      
      
      context = connectionFactory.createContext("user", "password", JMSContext.AUTO_ACKNOWLEDGE);
      consumer = context.createConsumer(destination);
      
      
      consumer.setMessageListener(new MyMessageListener());
      
      

       

      If using HTTPS port we replace the provider URL by (not only the port is changed, also the prefix now is https-remoting)

      env.put(Context.PROVIDER_URL, "https-remoting://myserver:8443");
      
      

       

      Now what I don't understand is, that if HTTP and HTTPS ports are both open, it works. But if HTTP is blocked, it didn't work. But why, because we use "https-remoting://myserver:8443" as the provider url and there is no port 8080 involved. Do we have to use another Connection Factory? But how must this be configured on server side? I tried this one, but it didn't work:

       

       

      <subsystem xmlns="urn:jboss:domain:messaging:2.0">

          <hornetq-server>

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

       

       

              <connectors>

                  <http-connector name="http-connector" socket-binding="http">

                      <param key="http-upgrade-endpoint" value="http-acceptor"/>

                  </http-connector>

                  <http-connector name="http-connector-throughput" socket-binding="http">

                      <param key="http-upgrade-endpoint" value="http-acceptor-throughput"/>

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

                  </http-connector>

                

                  <!-- new connector for https -->

                  <http-connector name="https-connector" socket-binding="https">

                      <param key="http-upgrade-endpoint" value="https-acceptor"/>

                  </http-connector>

                  <http-connector name="https-connector-throughput" socket-binding="https">

                      <param key="http-upgrade-endpoint" value="https-acceptor-throughput"/>

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

                  </http-connector>

                

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

              </connectors>

       

       

              <acceptors>

                  <http-acceptor http-listener="default" name="http-acceptor"/>

                  <http-acceptor http-listener="default" name="http-acceptor-throughput">

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

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

                  </http-acceptor>

                

                  <!-- new acceptor for https -->

                  <http-acceptor http-listener="https" name="https-acceptor"/>

                  <http-acceptor http-listener="https" name="https-acceptor-throughput">

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

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

                  </http-acceptor>

                

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

              </acceptors>

              ...

              <jms-connection-factories>

                  ...

                  <connection-factory name="SslRemoteConnectionFactory">

                      <connectors>

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

                      </connectors>

                      <entries>

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

                      </entries>

                  </connection-factory>

                  ...

              </jms-connection-factories>

              ...

          </hornetq-server>

      </subsystem>

       

      The exception thrown in case of an error is:

      [WARN ] [28.07.2014 10:50:35] Error creating JMS connection

      javax.jms.JMSRuntimeException: Failed to create session factory

        at org.hornetq.jms.client.JmsExceptionUtils.convertToRuntimeException(JmsExceptionUtils.java:98)

        at org.hornetq.jms.client.HornetQConnectionFactory.createContext(HornetQConnectionFactory.java:149)

        at de.demo.AbstractBaseCommand.execute(AbstractBaseCommand.java:113)

        at de.demo.CommandTask.doInBackground(CommandTask.java:52)

        at javax.swing.SwingWorker$1.call(Unknown Source)

        at java.util.concurrent.FutureTask.run(Unknown Source)

        at javax.swing.SwingWorker.run(Unknown Source)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

        at java.lang.Thread.run(Unknown Source)

      Caused by: javax.jms.JMSException: Failed to create session factory

        at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:673)

        at org.hornetq.jms.client.HornetQConnectionFactory.createContext(HornetQConnectionFactory.java:139)

        ... 8 more

      Caused by: HornetQNotConnectedException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]

        at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:905)

        at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:669)

        ... 9 more

      Just to mention, we are using JBoss Wildfly 8.1.0.FINAL.

       

      Regards, Markus