# Connection Refused in Azure IOT HUB

**URL:** https://discourse.nodered.org/t/connection-refused-in-azure-iot-hub/65518
**Category:** General
**Created:** [24 July 2022 05:33 UTC](https://discourse.nodered.org/t/connection-refused-in-azure-iot-hub/65518 "2022-07-24T05:33:39Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)
#### Post date: [24 July 2022 05:33 UTC](https://discourse.nodered.org/t/connection-refused-in-azure-iot-hub/65518/1 "2022-07-24T05:33:39Z")

</div>

```auto
[
    {
        "id": "1c0fb3c4214105c2",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "191eb7ca.b71a8",
        "type": "azureiothub",
        "z": "1c0fb3c4214105c2",
        "name": "Azure IoT Hub",
        "protocol": "mqtt",
        "x": 440,
        "y": 160,
        "wires": [
            [
                "39c7854c.56d18a"
            ]
        ]
    },
    {
        "id": "aa561f4a.a44358",
        "type": "function",
        "z": "1c0fb3c4214105c2",
        "name": "Function",
        "func": "msg1 = '{\"deviceID\": \"Arduino001\", '\nmsg1 = msg1 + '\"SAK\": \"Yub6LJ9vjuPaJ4zWXCPEYr8+eRByyCUwB3h8VefIlEE=\", ' \nmsg1 = msg1 + '\"Protocol\": \"mqtt\", '\nmsg1 = msg1 + '\"Data\": { \"' + msg.topic + '\": \"' + msg.payload + '\"}}'\n\nnewMsg = { payload: msg1 };\nreturn newMsg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 304,
        "y": 322,
        "wires": [
            [
                "191eb7ca.b71a8",
                "39c7854c.56d18a"
            ]
        ]
    },
    {
        "id": "48115883.03fae8",
        "type": "inject",
        "z": "1c0fb3c4214105c2",
        "name": "Speed",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "speed",
        "payload": "345",
        "payloadType": "num",
        "x": 121,
        "y": 287,
        "wires": [
            [
                "aa561f4a.a44358"
            ]
        ]
    },
    {
        "id": "39c7854c.56d18a",
        "type": "debug",
        "z": "1c0fb3c4214105c2",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 608.3400268554688,
        "y": 250.47998046875,
        "wires": []
    },
    {
        "id": "31ae88af.f84fa",
        "type": "inject",
        "z": "1c0fb3c4214105c2",
        "name": "Temperature",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "temperature",
        "payload": "87",
        "payloadType": "num",
        "x": 139,
        "y": 323,
        "wires": [
            [
                "aa561f4a.a44358"
            ]
        ]
    },
    {
        "id": "fc5e350.8f97e48",
        "type": "inject",
        "z": "1c0fb3c4214105c2",
        "name": "Pressure",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "pressure",
        "payload": "2342",
        "payloadType": "num",
        "x": 129,
        "y": 359,
        "wires": [
            [
                "aa561f4a.a44358"
            ]
        ]
    },
    {
        "id": "f3fce0b1.76ed6",
        "type": "inject",
        "z": "1c0fb3c4214105c2",
        "name": "Send Multiple Values",
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "",
        "payload": "{\"deviceID\": \"Arduino001\", \"SAK\": \"Yub6LJ9vjuPaJ4zWXCPEYr8+eRByyCUwB3h8VefIlEE=\", \"Protocol\": \"mqtt\", \"Data\": { \"AvgFlowRate\" : 500, \"FlowRate\" : 700, \"AvgStaticPressure\" : 525, \"StaticPressure\" : 518, \"AvgCasingPressure\" : 776, \"CasingPressure\" : 805, \"AvgTubingPressure\" : 609, \"TubingPressure\" : 588}}",
        "payloadType": "json",
        "x": 150,
        "y": 180,
        "wires": [
            [
                "191eb7ca.b71a8"
            ]
        ]
    },
    {
        "id": "15aa66ba.d05be9",
        "type": "inject",
        "z": "1c0fb3c4214105c2",
        "name": "Send one value",
        "repeat": "",
        "crontab": "",
        "once": false,
        "topic": "",
        "payload": "{\"deviceID\": \"Arduino001\", \"SAK\": \"Yub6LJ9vjuPaJ4zWXCPEYr8+eRByyCUwB3h8VefIlEE=\", \"Protocol\": \"mqtt\", \"Data\": { \"Speed\" : \"25\"}}",
        "payloadType": "json",
        "x": 137.90994262695312,
        "y": 110.09001922607422,
        "wires": [
            [
                "191eb7ca.b71a8"
            ]
        ]
    },
    {
        "id": "24956e6.952af12",
        "type": "inject",
        "z": "1c0fb3c4214105c2",
        "name": "Send one value",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "{\"deviceID\": \"myiotdevice\", \"SAK\": \"dzerQ4wJGYG0DV/SetL49r3H+rFAhfdXOcFNeZWITc8=\", \"Protocol\": \"mqtt\", \"Data\": { \"Speed\" : \"25\"}}",
        "payloadType": "json",
        "x": 143,
        "y": 42,
        "wires": [
            [
                "191eb7ca.b71a8"
            ]
        ]
    }
]

```

Dear Node Red Support Team,  
I am trying to send some payload to azure IOT HUB but I am facing connection not established related problem.Are there any Permissions which need to be changed in Azure portal.Please Kindly support on this issue as soon as possible.

 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/58044fb3bfe974e7bba4b043d91528bba4bf63a6.png)  
 ![2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8e785c48a745a96aa58e213c7db3ef2de56e21fc.png)

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [24 July 2022 13:37 UTC](https://discourse.nodered.org/t/connection-refused-in-azure-iot-hub/65518/2 "2022-07-24T13:37:27Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/2/f2b6a0fd6db90e189871b60de9e4d117e5bd850c.png)

You are not passing the required data - see the parts that have "undefined" against them.

---

<div class="post-metadata">

### Author: ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)
#### Post date: [25 July 2022 06:10 UTC](https://discourse.nodered.org/t/connection-refused-in-azure-iot-hub/65518/3 "2022-07-25T06:10:35Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/66b78b9298b88fe1ee7787b535b2b31e218e2cdc.png)  
 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/75c19bee547806fa030318f002b69b0a7f9232f2.png)

[HostName=iotstream.azure-devices.net](http://HostName=iotstream.azure-devices.net);DeviceId=myiotdevice;SharedAccessKey=dzerQ4wJGYG0DV/SetL49r3H+rFAhfdXOcFNeZWITc8=  
Even After above settings done correctly.Still Not getting Connected.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [25 July 2022 08:32 UTC](https://discourse.nodered.org/t/connection-refused-in-azure-iot-hub/65518/4 "2022-07-25T08:32:25Z")

</div>

What errors are you getting now?

---

<div class="post-metadata">

### Author: ![bachloo.rahul](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bachloo.rahul](https://discourse.nodered.org/u/bachloo.rahul)
#### Post date: [25 July 2022 16:53 UTC](https://discourse.nodered.org/t/connection-refused-in-azure-iot-hub/65518/5 "2022-07-25T16:53:28Z")

</div>

> [@TotallyInformation](#):
>
> You are not passing the required data - see the parts that have "undefined" against them.

First while Injecting a payload from inject node it shows Azure Iot Hub node disconnected.  
And Secondly my node red suddenly stops after injecting a payload to Azure IOt HUb.If same is happening your side also kindly check to see.  
v

 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/58044fb3bfe974e7bba4b043d91528bba4bf63a6.png)

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [25 July 2022 20:14 UTC](https://discourse.nodered.org/t/connection-refused-in-azure-iot-hub/65518/6 "2022-07-25T20:14:50Z")

</div>

While the node certainly should not error like it does, you are told quite clearly what the issue is:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f69a9a0eba431e800d6f933256133ac74e0a6d5d.png)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [23 September 2022 20:15 UTC](https://discourse.nodered.org/t/connection-refused-in-azure-iot-hub/65518/7 "2022-09-23T20:15:31Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
