# Value to another Node Red

**URL:** <https://discourse.nodered.org/t/value-to-another-node-red/64546>\
**Category:** General\
**Created:** [30 June 2022 13:09 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546 "2022-06-30T13:09:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [30 June 2022 13:09 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/1 "2022-06-30T13:09:21Z")

</div>

Hi!

I would like to send a value to another Node Red.  
The two are connected via a VPN.  
What's the best way to do this?

Many thanks for the help

---

<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:** [30 June 2022 13:13 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/2 "2022-06-30T13:13:39Z")

</div>

> [@madmax](#):
>
> What's the best way to do this?

Best subjective.

Recommended...

1. Use MQTT (very easy, very quick)
2. Add HTTP Endpoints and call them via HTTP-Request (examples in cookbook)

Possible but harder to implement...

1. Websockets
2. Custom TCP or UDP in/out coms

Others...  
There are loads more options and protocols but the above are most common and most accessible

---

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [30 June 2022 13:16 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/3 "2022-06-30T13:16:28Z")

</div>

Hi!

Thank you for your message.

I tried MQTT but that doesn't work. But it doesn't go to the other Node Red locally. Do you have a template?

---

<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:** [30 June 2022 13:24 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/4 "2022-06-30T13:24:22Z")

</div>

1. What did you try (show us what you did)
2. Do you have an MQTT broker installed somewhere that is accessible at both sides of the VPN?

2 extra question (for another idea)

- Are the 2 node-reds able to connect out to the internet?
- Are you opposed to using a public MQTT broker (i.e. are the values non-critical)

---

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [30 June 2022 13:30 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/5 "2022-06-30T13:30:57Z")

</div>

Hi!

The connection between the two computers is fine. ping works.

Here's my flow. if I enter localhost it works. But when I enter the IP address of the computer, it doesn't work.

With 127.0.0.1 it also doesn't work anymore with 192.168.2.70.

Do you have to postage there?

```auto
[
    {
        "id": "8de16c7cd6d3b6e2",
        "type": "debug",
        "z": "3f64db42580815a4",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 870,
        "y": 440,
        "wires": []
    },
    {
        "id": "3ffebe63cb5f8474",
        "type": "inject",
        "z": "3f64db42580815a4",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "TEST",
        "payload": "",
        "payloadType": "date",
        "x": 360,
        "y": 360,
        "wires": [
            [
                "4d5183a1894e7f2a"
            ]
        ]
    },
    {
        "id": "4d5183a1894e7f2a",
        "type": "mqtt out",
        "z": "3f64db42580815a4",
        "name": "",
        "topic": "",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "eb07043b2a90be54",
        "x": 550,
        "y": 340,
        "wires": []
    },
    {
        "id": "dd8f18a3def351e9",
        "type": "mqtt in",
        "z": "3f64db42580815a4",
        "name": "",
        "topic": "TEST",
        "qos": "0",
        "datatype": "auto",
        "broker": "eb07043b2a90be54",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 710,
        "y": 440,
        "wires": [
            [
                "8de16c7cd6d3b6e2"
            ]
        ]
    },
    {
        "id": "eb07043b2a90be54",
        "type": "mqtt-broker",
        "name": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

```

---

<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:** [30 June 2022 13:35 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/6 "2022-06-30T13:35:56Z")

</div>

Any chance you could answer the rest of the questions?

Also, include IP address info of the 2 node-red devices AND which of the 2 devices have an MQTT broker installed.

---

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [30 June 2022 13:40 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/7 "2022-06-30T13:40:57Z")

</div>

Hi!

Yes.

I have installed mosquito.

Send

 ![Bildschirmfoto 2022-06-30 um 15.39.59](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/0/a02d92b94b4d8d9518f40a71df49faa0e7372bf1.png)

Server

 ![Bildschirmfoto 2022-06-30 um 15.39.49](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/d/9d6989c3aa9824e309c16089d49986279e5c6143.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:** [30 June 2022 13:57 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/8 "2022-06-30T13:57:35Z")

</div>

So this is your problem - you have 2 brokers.

By definition, a broker is a MIDDLE MAN

e.g. `node-red1` ←→ `single broker` ←→ `node-red2`

The MQTT broker can be on any one of your computers - BUT - for the 2 node-red instances to talk to each other, the MQTT Nodes on BOTH node-reds MUST point to the SAME broker.

---

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [30 June 2022 14:07 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/9 "2022-06-30T14:07:38Z")

</div>

Hi!

OK. but if I specify the same IP address for both of a Node Red, unfortunately it doesn't work either.

Can you please write what I have to set there?

---

<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:** [30 June 2022 14:10 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/10 "2022-06-30T14:10:42Z")

</div>

> [@madmax](#):
>
> Can you please write what I have to set there?

You enter the IP of 1 broker (you chose) in the MQTT Config of both Node-REDs.

I am not sure how to be any more clear.

> [@madmax](#):
>
> OK. but if I specify the same IP address for both of a Node Red, unfortunately it doesn't work either

The IP of your 2 node-red instances should be different BUT the IP set in the MQTT Config should point to 1 MQTT Broker.

* * *

If you had answered my previous questions I would have suggested you use a public broker as a test - but you neglect to answer all questions.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [30 June 2022 14:29 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/11 "2022-06-30T14:29:49Z")

</div>

Are your two computers at addresses 192.168.1.252 and 192.168.2.70?

From 192.168.1.252 can you successfully ping 192.168.2.70?  
From 192.168.2.70 can you succesfully ping 192.168.1.252?

Is mosquitto running on 192.168.1.252?  
What does the file /etc/mosquitto/mosquitto.conf contain?

---

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [30 June 2022 14:33 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/12 "2022-06-30T14:33:50Z")

</div>

Hi!

Yes ping goes from both sides.

Yes 192.168.1.252

in /etc/mosquitto/mosquitto.conf was not changed. This is original.

They think the problem is that the mosquitto cannot be reached from the outside. What do you have to put in there is /etc/mosquitto/mosquitto.conf?

---

<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:** [30 June 2022 14:37 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/13 "2022-06-30T14:37:48Z")

</div>

> [@madmax](#):
>
> in /etc/mosquitto/mosquitto.conf was not changed. This is original

In which case that is your issue.

You need to modify mosquitto conf to allow external access.

Starting with the release of Mosquitto version 2.0.0 the default config will only bind to `localhost` as a move to a more secure default posture.

If you want to be able to access the broker from other machines you will need to explicitly edit the config files to either add a new `listener` that binds to the external IP address (or 0.0.0.0) or add a `bind` entry for the default listener.

More details can be found in the 2.0 release notes [here](https://mosquitto.org/blog/2020/12/version-2-0-0-released/)

In simple terms, put ...

```auto
listener 1883 0.0.0.0

```

in mosquitto.conf

---

<div class="post-metadata">

**Author:** ![madmax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@madmax](https://discourse.nodered.org/u/madmax)\
**Post date:** [30 June 2022 14:49 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/14 "2022-06-30T14:49:55Z")

</div>

Hi!

Thank you for the help, it works now

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 June 2022 14:50 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/15 "2022-06-30T14:50:50Z")

</div>

If you are running on a Linux system it is better not to modify the master mosquitto.conf file, as it may get overwritten by an update. It is better to add an override file in /etc/mosquitto/conf.d  
I add a file to that directory called mossy.conf and put the listener line in there. If you are not using users and passwords then you might also need  
`allow_anonymous true`

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [30 June 2022 14:51 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/16 "2022-06-30T14:51:59Z")

</div>

I think you need to add this line as well.

![mos_all](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/d/9db896894ac7fbde11af4f850a1136110c8c63cd.png)

 ![mos_auth](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/2/328dde846cd90d2f7d4801b689b6feda50b2b3e6.png)

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [30 June 2022 15:17 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/17 "2022-06-30T15:17:11Z")

</div>

I wish I would've read this thread a few days ago. I just had a similar request to send payloads from a Node-RED instance on my home network to a Node-RED instance on my brothers home network.

The solution I ended up on was using `node-red-contrib-webhookrelay` and it works well. However, had I known I could've setup my MQTT broker to transfer data, I might have gone with that. I went with webhookrelay because I didn't want to have my brother expose his entire Node-RED port (as he is less tech savvy).

As far a security is concerned, can anyone rank them or compare them to assist others in choosing a quality solution.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [30 June 2022 17:16 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/18 "2022-06-30T17:16:35Z")

</div>

I have zero knowledge of the node you mentioned.  
However, if you are accessing one private network from another, over the internet (which according to his ping results @madmax is not doing), you have to allow connections from the internet to at least one network. This is a security risk whatever protocol you use.

For such a case I would use a cloud based MQTT broker or else some sort of VPN, wireguard or zerotier perhaps.

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [30 June 2022 17:47 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/19 "2022-06-30T17:47:07Z")

</div>

My brother does have a VPN setup but I think its Nord...

In no order the options I considered were:

1. setup authentication and expose his node-red server to the web and use HTTP nodes
2. localtunnel to expose a port
3. ngrok to expose a port
4. webhookrelay
5. setup authentication and expose MQTT broker to the web
6. forward a tcp/udp port and connect to it with tcp nodes

I settled on the webhookrelay method because it seemed somewhat secure and easy to setup, but I'm not dead set on keeping it setup this way if there are better alternatives.

---

<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:** [29 August 2022 17:47 UTC](https://discourse.nodered.org/t/value-to-another-node-red/64546/20 "2022-08-29T17:47:57Z")

</div>

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