tkurki / signalk-mqtt-gw

Signal K server plugin that provides gateway functionality between Signal K and MQTT
Apache License 2.0
14 stars 7 forks source link

Connection to Azure IoT Hub #10

Closed miquelmp closed 4 years ago

miquelmp commented 5 years ago

Congrats for your great job with the Signal K project!!!

I have a problem when I try to conennect Signal K - MQTT Gateway to Azure IoT Hub. Do you have more documentation? I've tried to connect with the same server, user and password that work when I connect via MQTTBox, but I get the message Error: Connection refused: Not authorized, with all the messages attached below.

image

Error: Connection refused: Not authorized at MqttClient._handleConnack (/home/pi/.signalk/node_modules/mqtt/lib/client.js:735:9) at MqttClient._handlePacket (/home/pi/.signalk/node_modules/mqtt/lib/client.js:296:12) at process (/home/pi/.signalk/node_modules/mqtt/lib/client.js:238:12) at Writable.writable._write (/home/pi/.signalk/node_modules/mqtt/lib/client.js:248:5) at doWrite (/home/pi/.signalk/node_modules/mqtt/node_modules/readable-stream/lib/_stream_writable.js:237:10) at writeOrBuffer (/home/pi/.signalk/node_modules/mqtt/node_modules/readable-stream/lib/_stream_writable.js:227:5) at Writable.write (/home/pi/.signalk/node_modules/mqtt/node_modules/readable-stream/lib/_stream_writable.js:194:11) at TLSSocket.ondata (_stream_readable.js:639:20) at emitOne (events.js:116:13) at TLSSocket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at TLSSocket.Readable.push (_stream_readable.js:208:10) at TLSWrap.onread (net.js:607:20) { path: 'navigation.speedOverGround', value: 3.0352229911453805, context: 'vessels.urn:mrn:signalk:uuid:e5003297-c689-4ca8-85e9-5a7c0b132cd5', source: { sentence: 'VTG', talker: 'II', type: 'NMEA0183', label: 'nmea0183-sample-data' }, '$source': 'nmea0183-sample-data.II', timestamp: '2019-09-02T16:29:10.696Z' }

MQTTBox working settings image

What am I doing wrong?

Best Regards!

Miquel

tkurki commented 5 years ago

This is all Azure IoT Hub MQTT specific and I don't have any experience there.

Try the code in https://stackoverflow.com/questions/51711853/connect-to-azure-iothub-using-mqtt-in-javascript. Once you get that working let me know.

One obvious thing missing in the plugin is clientId, which you can not specify with the current version. That is straightforward to add, but I want to see a working code sample before investing time on debugging this.

miquelmp commented 5 years ago

Hello. I tried the code you told me and the answer code works.

I could connect and publish on Azure IoT Hub!

tkurki commented 4 years ago

Oops, this wasn't really fixed. Is this still relevant? If it is please reopen.