Folks, I have been struggling with a similar issue. Have not been able to resolve it in the last week of trying.
I have OH2 running on a Raspberry Pi3. All fine. I am now trying to publish my ZWAVE events to IBM Watson’s IOT (mqtt) broker.
Watson cloud environment has been set up properly.
I can connect to the MQTT broker using a standalone client on my Mac (MQTTBox). Through that, I could verify that the URL / Username / Password are all ok. Connecting to Watson from the RPI3 however keeps failing with the following message:
11:39:54.082 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'watsoniot’
11:39:55.439 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
Not authorized to connect (5)
My /etc/openhab2/services/mqtt.cfg looks as follows:
I already deleted the /var/lib/openhab2/config/org/openhab/mqtt.config as sugested in this thread and it got rebuilt showing the same values as the mqtt.cfg file, yet with double quotes (" ") around them, eg: watsoniot.url=“tcp://myorgid.messaging.internetofthings.ibmcloud.com:1883”
There are no other brokers listed in this file either.
Again, I am fairly (if not 100%) certain that the credentials are ok, as the stand-alone client successfully connects and Watson also sees it come online. OH2 however will not connect.
What am I missing? How can I further debug this within OH2?
I do not believe that OH MQTT supports encrypted TLS connections. If Watson’s broker is configured to encrypt the message traffic using SSL/TLS, I don’t think you can connect to it.
The error is showing that OH can see the broker and it attempts to connect. If you are certain the credentials are correct this is the main thing I can think of that could cause a Not authorized to connect error.
I do not know this Watson service but it seems to me that if you are not encrypting the traffic you potentially expose your username / password to everybody on the internet.
In any case I would try to use tcpdump to see what is going on during the communication and compare it with another tcpdump capture from the successful communication using MQTTBox. By compating the authentication requests I am sure you will see differences that can point you to the right direction
2017-09-10 18:53:38.387 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-09-10 18:53:38.409 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'
2017-09-10 18:53:38.569 [INFO ] [ulation.internal.HueEmulationServlet] - Started Hue Emulation service at /api
2017-09-10 18:53:38.671 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
Unable to connect to server (32103) - java.net.ConnectException: Connection refused (Connection refused)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)[:1.8.0_121]
... 2 more
when I use the karaf console as suggested here this is what is listed out: