Hi Jimmi:
Thank you very much. I'll check your example and try again. Thanks. ------------------ 原始邮件 ------------------ 发件人: "Jimmi Dyson";<[email protected]>; 发送时间: 2014年9月2日(星期二) 晚上10:21 收件人: "users"<[email protected]>; 主题: Re: How to Enable SSL on Camel MQTT component Hi, Is the ActiveMQ (I'm assuming you're using ActiveMQ!) MQTT transport connector configured to listen on 61617? Are you sure that's not a non-MQTT (perhaps SSL-configured Openwire) transport connector on 61617? FYI there is a IANA port reserved (8883) for MQTT over SSL, although of course you can use whatever port you want. Make sure you've set "-Djavax.net.ssl.trustStore=<PATH_TO_TRUSTSTORE> -Djavax.net.ssl.trustStorePassword=<TRUSTSTORE_PASSWORD>" correctly if you're using a self-signed server certificate or your own CA for issuing the server certificate. If you're using a public CA then this shouldn't be necessary. I've pushed an example with some tests including ActiveMQ SSL-configured test with self-signed cert to https://github.com/jimmidyson/camel-examples/tree/master/activemq-mqtt. Jimmi On 2 September 2014 12:04, Charles Moulliard <[email protected]> wrote: > Hi, > > I think that debugging will be required as you get a message type = 0 (see > code here : > > https://github.com/fusesource/mqtt-client/blob/master/mqtt-client/src/main/java/org/fusesource/mqtt/client/CallbackConnection.java#L335 > ) > As you have configured your ActiveMQ Transport connector to use MQTT + SSL, > I assume that it has been configured like that ? > http://rijware.com/securing-mqtt-on-apache-activemq/ > > Regards, > > > > On Tue, Sep 2, 2014 at 10:57 AM, clever <[email protected]> wrote: > > > I saw the page of http://camel.apache.org/mqtt.html said mqtt component > > supports to use ssl connection. but didn't mention how to enable it. > > > > > > I tried to change the protocol to ssl, and also set the system > properties: > > > > > javax.net.ssl.keyStore/javax.net.ssl.keyStorePassword/javax.net.ssl.TrustStore > > > > > > Besides, I also tried to set a customized SSLContext to MQTTConfiguration > > . both of them don't work. > > > > > > The error looks like: > > Exception in thread "main" org.apache.camel.FailedToCreateRouteException: > > Failed to create route route1: > > Route(route1)[[From[mqtt:bar?host=ssl://localhost:61617]] ->... because > of > > Failed to resolve endpoint: mqtt://bar?host=ssl%3A%2F%2Flocalhost%3A61617 > > due to: Could not connect. Received unexpected command: 0 > > at > > > org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:180) > > at > > > org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:780) > > at > > > org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2068) > > at > > > org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1816) > > at > > > org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1683) > > at > > org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) > > at > > > org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1651) > > at > > org.apache.activemq.book.ch3.TestCamelMQTT.main(TestCamelMQTT.java:70) > > Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to > > resolve endpoint: mqtt://bar?host=ssl%3A%2F%2Flocalhost%3A61617 due to: > > Could not connect. Received unexpected command: 0 > > at > > > org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:534) > > at > > > org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:71) > > at > > > org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:190) > > at > > > org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:106) > > at > > > org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:112) > > at > > > org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:72) > > at > > > org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:88) > > at > > > org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:888) > > at > > > org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:175) > > ... 7 more > > Caused by: java.io.IOException: Could not connect. Received unexpected > > command: 0 > > at > > > org.fusesource.mqtt.client.CallbackConnection$LoginHandler$1.onTransportCommand(CallbackConnection.java:338) > > at > > > org.fusesource.hawtdispatch.transport.TcpTransport.drainInbound(TcpTransport.java:713) > > at > > > org.fusesource.hawtdispatch.transport.SslTransport.handshake(SslTransport.java:452) > > at > > > org.fusesource.hawtdispatch.transport.SslTransport.drainInbound(SslTransport.java:274) > > at > > > org.fusesource.hawtdispatch.transport.TcpTransport$6.run(TcpTransport.java:592) > > at > > > org.fusesource.hawtdispatch.internal.NioDispatchSource$3.run(NioDispatchSource.java:209) > > at > > > org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:100) > > at > > > org.fusesource.hawtdispatch.internal.pool.SimpleThread.run(SimpleThread.java:77) > > > > > > > > > > > > I tried the way on a plain Java App by using ActiveMQSslConnectionFactory > > to connect to it, it works to read message from/write message to > Activemq. > > > > > > I used Activemq 5.10 with ssl transport enabled as Server side. > > > > > > I appreciate if anybody can give me some hints. > > > > > > Thanks in advance. > > > > > -- > Charles Moulliard > Apache Committer / Architect @RedHat > Twitter : @cmoulliard | Blog : http://cmoulliard.github.io >
