# Ip advanced loop msg.host

**URL:** <https://discourse.nodered.org/t/ip-advanced-loop-msg-host/52459>\
**Category:** General\
**Created:** [20 October 2021 12:25 UTC](https://discourse.nodered.org/t/ip-advanced-loop-msg-host/52459 "2021-10-20T12:25:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ketpa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ketpa/32/42496_2.png) [@ketpa](https://discourse.nodered.org/u/ketpa)\
**Post date:** [20 October 2021 12:25 UTC](https://discourse.nodered.org/t/ip-advanced-loop-msg-host/52459/1 "2021-10-20T12:25:56Z")

</div>

I have array with ip

```auto
[{"nazwa":"T1","ip":"10.0.0.71","opis_ip_alarm":"ip alarm 1"},{"nazwa":"T2","ip":"10.0.0.72","opis_ip_alarm":null}]

```

how loop msg.host by ip  
I try this

```auto
[
    {
        "id": "4f61a7737e17d8d3",
        "type": "adv ping",
        "z": "e79cd8495882236e",
        "name": "",
        "host": "",
        "x": 450,
        "y": 160,
        "wires": [
            [
                "549a4d06d5505586",
                "6cab19e646867a6b"
            ]
        ]
    },
    {
        "id": "20bdc2a9b89d78ca",
        "type": "function",
        "z": "e79cd8495882236e",
        "name": "",
        "func": "var ip = msg.payload;\nvar query = [];\n\nfor (var i = 0; i < ip.length; i++) {\n query[i]=ip[i].ip\n}\nmsg.query.forEach(query => node.send({host: query}))\n\nmsg.ip = query;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 270,
        "y": 160,
        "wires": [
            [
                "4f61a7737e17d8d3"
            ]
        ]
    },
    {
        "id": "62bb480eeab3e30e",
        "type": "inject",
        "z": "e79cd8495882236e",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[{\"nazwa\":\"T1\",\"ip\":\"10.0.0.71\",\"opis_ip_alarm\":\"ip alarm 1\"},{\"nazwa\":\"T2\",\"ip\":\"10.0.0.72\",\"opis_ip_alarm\":null}]",
        "payloadType": "json",
        "x": 90,
        "y": 160,
        "wires": [
            [
                "20bdc2a9b89d78ca"
            ]
        ]
    },
    {
        "id": "549a4d06d5505586",
        "type": "debug",
        "z": "e79cd8495882236e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 610,
        "y": 160,
        "wires": []
    }
]

```

![obraz](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b6d5307db2b0712cda5c27ac4865a31f1067d5f4.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 October 2021 12:37 UTC](https://discourse.nodered.org/t/ip-advanced-loop-msg-host/52459/2 "2021-10-20T12:37:37Z")

</div>

the quick answer is Dont Loop!

Use `node-red-node-ping` (its by node-red developers) - simply send it your array - it does the rest.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87c676f787d04572ce43b9450133962ad0bcf86f.png)

demo flow...

```auto
[
    {
        "id": "62bb480eeab3e30e",
        "type": "inject",
        "z": "68b1a8b9504a0d41",
        "name": "array of objects with host ip and name",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[{\"name\":\"T1\",\"host\":\"10.0.0.71\",\"opis_ip_alarm\":\"ip alarm 1\"},{\"name\":\"T2\",\"host\":\"10.0.0.72\",\"opis_ip_alarm\":null}]",
        "payloadType": "json",
        "x": 1190,
        "y": 160,
        "wires": [
            [
                "4edba8054cfbc9dd"
            ]
        ]
    },
    {
        "id": "549a4d06d5505586",
        "type": "debug",
        "z": "68b1a8b9504a0d41",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1290,
        "y": 280,
        "wires": []
    },
    {
        "id": "4edba8054cfbc9dd",
        "type": "ping",
        "z": "68b1a8b9504a0d41",
        "protocol": "Automatic",
        "mode": "triggered",
        "name": "",
        "host": "",
        "timer": "20",
        "inputs": 1,
        "x": 1290,
        "y": 220,
        "wires": [
            [
                "549a4d06d5505586"
            ]
        ]
    }
]

```

---

<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:** [3 November 2021 12:37 UTC](https://discourse.nodered.org/t/ip-advanced-loop-msg-host/52459/3 "2021-11-03T12:37:59Z")

</div>

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