Value to another Node Red

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

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

1 Like

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?

  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)

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?

[
    {
        "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": ""
    }
]

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.

Hi!

Yes.

I have installed mosquito.

Send

Server

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.

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?

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.

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.

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?

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?

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

In simple terms, put ...

listener 1883 0.0.0.0

in mosquitto.conf

Hi!

Thank you for the help, it works now

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

I think you need to add this line as well.

mos_all

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.

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.

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.

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