2 Replies Latest reply on Jun 19, 2012 12:23 PM by cyf

    Exceptions with ssl transportation using direct JMS instantiation

    cyf

      Hi,

       

      I am trying to try ssl in Hornetq using using direct JMS instantiation. Unfortunately, I got following exception at creating connection.

        HornetQException[errorCode=2 message=Cannot connect to server(s). Tried with all available servers.]

       

      The connectors and acceptors defined as:

      <connectors>

            <connector name="netty">

               <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>

               <param key="host"  value="${hornetq.remoting.netty.host:localhost}"/>

               <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>

               <param key="ssl-enabled" value="true"/>

               <param key="key-store-path" value="hornetq.example.keystore"/>

               <param key="key-store-password" value="hornetqexample"/>

            </connector>

           

            <connector name="netty-throughput">

               <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>

               <param key="host"  value="${hornetq.remoting.netty.host:localhost}"/>

               <param key="port"  value="${hornetq.remoting.netty.batch.port:5455}"/>

               <param key="ssl-enabled" value="true"/>

               <param key="key-store-path" value="hornetq.example.keystore"/>

               <param key="key-store-password" value="hornetqexample"/>

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

            </connector>

         </connectors>

       

         <acceptors>

            <acceptor name="netty">

               <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>

               <param key="host"  value="${hornetq.remoting.netty.host:localhost}"/>

               <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>

               <param key="ssl-enabled" value="true"/>

               <param key="key-store-path" value="hornetq.example.keystore"/>

               <param key="key-store-password" value="hornetqexample"/>

               <param key="trust-store-path" value="hornetq.example.truststore"/>

               <param key="trust-store-password" value="hornetqexample"/>

            </acceptor>

           

            <acceptor name="netty-throughput">

               <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>

               <param key="host"  value="${hornetq.remoting.netty.host:localhost}"/>

               <param key="port"  value="${hornetq.remoting.netty.batch.port:5455}"/>

               <param key="ssl-enabled" value="true"/>

               <param key="key-store-path" value="hornetq.example.keystore"/>

               <param key="key-store-password" value="hornetqexample"/>

               <param key="trust-store-path" value="hornetq.example.truststore"/>

               <param key="trust-store-password" value="hornetqexample"/>

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

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

            </acceptor>

         </acceptors>

       

      The hornetq-jms.xml is the default one for non-clustered. The line in red is where the exception is thrown.

       

      The java code is

              final Map<String, Object> map = new HashMap<String, Object>();

              map.put(TransportConstants.HOST_PROP_NAME, "192.168.1.101"); //brokerUrl

              map.put(TransportConstants.PORT_PROP_NAME, 5445);

              

            TransportConfiguration tc = new TransportConfiguration(NettyConnectorFactory.class.getName(), map);       

              ConnectionFactory cf = (ConnectionFactory) HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, tc);

             

              Connection connection = null;                 

             try {

                 connection = cf.createConnection(userName, password);      

              }catch (JMSException e) {

                  .............

              }

       

      Thank you in advance for your help!

       

      Yun

        • 1. Re: Exceptions with ssl transportation using direct JMS instantiation
          edh

          Hi Yun.  I don't know why, but whenever I define any connectors or acceptors with "localhost", I get the same error.  It seems like, with Netty, I need to use the machine name instead of localhost.  Even though they are running on the same machine.

           

          I don't know why.  All I know is if I don't use localhost, I can connect fine.

           

          Hope this helps,

          Ed

          • 2. Re: Exceptions with ssl transportation using direct JMS instantiation
            cyf

            Hi Ed,

             

            Thank you very much for your reply.

             

            I use Tomcat instead of Netty. When debugged into source codes of HornetQ, I found the parameters regarding SSL were retrieved from the map passed to TransportConfiguration not from the configuration file.Don't know if this is a bug.

             

            Thank you again,

            Yunfeng