0 Replies Latest reply on Jun 24, 2013 12:45 PM by Zahid Saleem

    SSL Enabled HornetQ Connector wont connect.

    Zahid Saleem Newbie



      I am currently struggling to connect to an SSL enabled JMS Queue using HornetQConnectionFactory in JBoss 6.1.0-Final


      My Server is basically running the ssl-enabled hornetQ example configuration and using the default keys(keystore, truststore) provided - the server loads up successfully with no errors and is listening on port 5500.


      The Client is a pragmatic JMS Producer Wrapper for HornetQ Connector and should connect to the Server, however it fails to connect.  The following code illustrates how i create the connection


              Map<String, Object> connParams = new HashMap<String, Object>();
              connParams.put(org.hornetq.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, port);
              connParams.put(org.hornetq.core.remoting.impl.netty.TransportConstants.HOST_PROP_NAME, host);
              connParams.put(org.hornetq.core.remoting.impl.netty.TransportConstants.SSL_ENABLED_PROP_NAME, true);
              connParams.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, "hornetqexample");
              connParams.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, "/opt/cert/hornetq.example.keystore");
              TransportConfiguration transConfig =
                      new TransportConfiguration(NettyConnectorFactory.class.getName(), connParams);
              hcf = new HornetQJMSConnectionFactory(false, transConfig);
              try {
                  Queue queue;
                  queue = new HornetQQueue(queueName);
                  if (username != null && password != null) {
                      connection = hcf.createConnection(username, password); //fails here
                  } else {
                      connection = hcf.createConnection();
                  session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                  producer = session.createProducer(queue);
                  connected = true;
              } catch (JMSException ex) {
                  // Throw an exception that can be handled by the caller
                  logger.error("Problem creating JMS connection", es);
                  // Disconnect so that we clean up any partially created components
                  throw commsEx;
      The above works when SSL is disabled - however when SSL is enabled the server side errors with
      17:07:41,024 INFO  [org.jboss.bootstrap.impl.base.server.AbstractServer] JBossAS [6.1.0.Final "Neo"] Started in 35s:923ms
      17:12:51,067 ERROR [org.jboss.xnio.channel-listener] A channel event listener threw an exception: java.lang.IllegalArgumentException
              at java.nio.ByteBuffer.allocate(ByteBuffer.java:311) [:1.6.0_45]
              at org.jboss.xnio.channels.MessageStreamChannelListener.handleEvent(org.jboss.xnio.channels.MessageStreamChannelListener:108)
              at org.jboss.xnio.channels.MessageStreamChannelListener.handleEvent(org.jboss.xnio.channels.MessageStreamChannelListener:1) [
              at org.jboss.xnio.IoUtils.invokeChannelListener(org.jboss.xnio.IoUtils:536) [:6.1.0.Final]
              at org.jboss.xnio.nio.NioTcpChannel$ReadHandler.run(NioTcpChannel.java:389) [:6.1.0.Final]
              at org.jboss.xnio.IoUtils$2.execute(org.jboss.xnio.IoUtils:71) [:6.1.0.Final]
              at org.jboss.xnio.nio.NioSelectorRunnable.run(NioSelectorRunnable.java:115) [:6.1.0.Final]
              at java.lang.Thread.run(Thread.java:662) [:1.6.0_45]
              at org.jboss.threads.JBossThread.run(JBossThread.java:122) [:2.0.0.CR7]
      LIke i mentioned before the Server side hornetQ configuration is almost identicle to the ssl-enabled jms example that comes shipped with hornetQ dist 
      There are Netty SSL Conenctors and Acceptors configured in the hornetq-configuration.xml the exampleQueue is created on the server side.  So am unsure why i cant connect 
      successfully from the client.  However the example does use JNDI lookup where as I am create a HornetQConnector to connect over SSL i wouldnt have thought that will be an issue.
      Any help on the above would be greatly appreciated.