0
votes

I'm trying to publish to a MQTT topic thanks to the appropriate Apache Camel MQTT component.

So in my spring context XML I have the following:

<camel:to uri="mqtt:test?host=ssl://myhost:8883&amp;publishTopicName=test&amp;userName=test&amp;password=test"/>

But I'm getting the following error at startup :

Failed to create Producer for endpoint: Endpoint[mqtt:test?host=ssl://myhost:8883&publishTopicName=test&userName=test&password=test]. Reason: java.lang.NullPointerException

Everything is working fine when not using ssl, the following configuration (regular tcp instead of ssl) is working well :

<camel:to uri="mqtt:test?host=tcp://myhost:1883&amp;publishTopicName=test&amp;userName=test&amp;password=test"/>

I've added the javax.net.ssl.trustStore JVM property pointing to my certificates store but without any effect.

Does someone already met this issue ? Is there something to specifically add in the spring DSL configuration file when using the camel mqtt component with ssl ?

EDIT : The stacktrace of the NPE :

Caused by: java.lang.NullPointerException at org.fusesource.hawtdispatch.transport.SslTransport.connecting(SslTransport.java:194) at org.fusesource.mqtt.client.CallbackConnection.createTransport(CallbackConnection.java:285) at org.fusesource.mqtt.client.CallbackConnection.connect(CallbackConnection.java:138) at org.apache.camel.component.mqtt.MQTTEndpoint.connect(MQTTEndpoint.java:305) at org.apache.camel.component.mqtt.MQTTProducer.doStart(MQTTProducer.java:38) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3219) at org.apache.camel.impl.DefaultCamelContext.doAddService(DefaultCamelContext.java:1209) at org.apache.camel.impl.DefaultCamelContext.addService(DefaultCamelContext.java:1170) at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:442) ... 33 more

1
You may add javax.net.debug=ssl to see in the log what's actually going on with SSL communication. There could be bunch of reasons behind the scene and depends on SSL requirements to hosts. i.e. server certificate, client certificate, private keys in case of two-way SSL and so on...Vadim
Can you post the stacktrace with the NPE and also tell us what version of Camel you useClaus Ibsen
I'm using version 2.16.0 of Camel. I Have edited the initial post to add the stacktrace related to this NPE. I'm also going to add the javax.net.debug=ssl java property to know more about the issue. Thanks.AlexW

1 Answers

0
votes

Debugging through javax.net.debug=ssl was useful.

Actually there were an issue on the java.security where the security.provider property was not set properly. That was manually changed for testing purpose related to another application.

Since, everything is working fine. Sorry for the post related to a internal specific mistake.

Alex.