'Node Red - Could not connect: getaddrinfo ENOTFOUND xxx-device-hub.azure-devices.net"
I'm new to node-red and I'm trying to create a simple flow of sending data to my Azure IoT hub using node-red. But whenever I send the data the get the following error "Could not connect: getaddrinfo ENOTFOUND xxx-device-hub.azure-devices.net"
. I tried with different Shared access keys with all permission but still the same. I am working over a proxy network. Please help as I'm not able to work because of this
you can import my node-red flow :
[
{
"id": "6f18f82cf1fb4430",
"type": "tab",
"label": "Flow 5",
"disabled": false,
"info": "",
"env": []
},
{
"id": "191eb7ca.b71a8",
"type": "azureiothub",
"z": "6f18f82cf1fb4430",
"name": "Azure IoT Hub",
"protocol": "mqtt",
"x": 640,
"y": 340,
"wires": [
[
"39c7854c.56d18a"
]
]
},
{
"id": "39c7854c.56d18a",
"type": "debug",
"z": "6f18f82cf1fb4430",
"name": "",
"active": true,
"console": "false",
"complete": "payload",
"x": 870,
"y": 340,
"wires": []
},
{
"id": "b73c20238ff65f0f",
"type": "inject",
"z": "6f18f82cf1fb4430",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 160,
"y": 340,
"wires": [
[
"d9b5bad69079e9ea"
]
]
},
{
"id": "d9b5bad69079e9ea",
"type": "function",
"z": "6f18f82cf1fb4430",
"name": "",
"func": "msg.payload ={\"deviceID\":\"DC_Tower_Clock\",\"SAK\":\"<Shared-access-key>\",\"Protocol\":\"mqtt\",\"Data\":{\"DC_sensor1values\":[0],\"DC_sensor1timestamp\":[1651774945]}}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 380,
"y": 340,
"wires": [
[
"191eb7ca.b71a8"
]
]
}
]
Solution 1:[1]
The problem is not with the access keys, it's with the hostname for your broker.
Error ENOTFOUND
means that the OS on the system you are running can not resolve xxx-device-hub.azure-devices.net
to an IP address.
Make sure you have entered the right hostname and their are no typos.
You can test by trying to ping the address outside Node-RED first.
Solution 2:[2]
There were couple of issues with my flow:
- inside the payload I did not have the configuration right (deviceID instead of deviceId and SAK instead of key)
- I had my protocol as MQTT when it was actually HTTP
- And the main problem was actually the company proxy, as I'm able to send the messages using my personal Laptop but with the same flow with my Work Laptop I'm not able to.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | hardillb |