Exceptions with ssl transportation using direct JMS instantiation
cyf May 29, 2012 11:23 AMHi,
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