Arduino IoT: send error: NotConnectedError: Cannot send while disconnected.

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

 

When working with IoTHub and Node.js, you will most likely use one of following packages: ‘azure-iot-device-http’ and/or ‘azure-iot-device-amqp’.

Unfortunately, when you try to start the app you might get following error:

>> Board connected...

Sending message: {"deviceId":"MyIoTGateway","location":"Frankfurt","celsius":24.96765380859375,"fahrenheit":76.94177685546876,"relativeHumidity":
19.409698486328125,"pressure":"100.5769","feet":327.315053125,"meters":99.765625}

send error: NotConnectedError: Cannot send while disconnected.

\azure-iot-device-amqp\node_modules\azure-iot-amqp-base\node_modules\amqp10\lib\amqp_client.js:156

    throw new Error('Must connect before creating links');

          ^

Error: Must connect before creating links

    at AMQPClient.createSender (C\azure-iot-device-amqp\node_modules\azure-iot-amqp-base\node_modules\amqp10\lib\amqp_client.js:156:11)

    at Amqp.send (\azure-iot-device-amqp\node_modules\azure-iot-amqp-base\lib\amqp.js:168:16)

    at Amqp.sendEvent \node_modules\azure-iot-device-amqp\lib\amqp.js:84:14)

    at Client.sendEvent (\node_modules\azure-iot-device\lib\client.js:255:19)

    at Component.<anonymous> (\IoTLabs\weather.js:76:14)

    at Component.emit (events.js:107:17)

    at Component.<anonymous> (\j5-sparkfun-weather-shield\index.js:66:11)

    at null.<anonymous> (C\j5-sparkfun-weather-shield\index.js:79:9)

    at wrapper [as _onTimeout] (timers.js:274:14)

    at Timer.listOnTimeout (timers.js:119:15)

The issue here is that AMQP ports 5671 and 5672 are blocked. The solution for this is described in this post at the bottom of the article:

http://developers.de/blogs/damir_dobric/archive/2016/02/25/azure-iot-connected-weather-station.aspx


Posted Feb 26 2016, 12:33 PM by Damir Dobric
developers.de is a .Net Community Blog powered by daenet GmbH.