Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. Node-RED
  4. Use Node-Red to Allow Multiple Connections to Ethernet Gateway?

Use Node-Red to Allow Multiple Connections to Ethernet Gateway?

Scheduled Pinned Locked Moved Node-RED
13 Posts 4 Posters 9.0k Views 8 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qu3Uk
    wrote on last edited by
    #4

    Wondering if you got anywhere with this? I was planning on moving to the MQTT Gateway and was wondering if Node-Red would provide TCP connectivity for various controllers as MQTT isn't widely supported etc.

    but this sounds like it could work as well?

    petewillP 1 Reply Last reply
    0
    • Q Qu3Uk

      Wondering if you got anywhere with this? I was planning on moving to the MQTT Gateway and was wondering if Node-Red would provide TCP connectivity for various controllers as MQTT isn't widely supported etc.

      but this sounds like it could work as well?

      petewillP Offline
      petewillP Offline
      petewill
      Admin
      wrote on last edited by
      #5

      @Qu3Uk said:

      Wondering if you got anywhere with this?

      No, not yet. I need to play with it some more. If you're using an serial gateway on a Raspberry Pi it should be working using @tbowmo's setup. I still need to play with @Anticimex's setup to see if I can get Ethernet working in the method described above. I think the key is socat but I just have been working on other projects. Never enough time!

      My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

      1 Reply Last reply
      0
      • tbowmoT Offline
        tbowmoT Offline
        tbowmo
        Admin
        wrote on last edited by
        #6

        I'm loving nodered more and more now. It's so easy to route messages around, and transforming them to suit different things.

        I'm still using domoticz as controller, but with nodered I have fixed a "bug" where domoticz have inverted the state of V_LOCK. And I'm able to send sensor data to influxdb as well, and advanced graphs created with grafana.

        I have a non mysensor arduino reporting usage from my electricity meter. Nodered is transforming the data to mysensors protocol and injects the data into the mysensors stream towards domoticz and influxdb.

        I can also emulate sensors, and new types, in order to check if a given controller is capable of understanding the sensor messages (used it to test some new features in domoticz)

        So nodered is a kind of Swiss army knife. It can do almost everything :)

        1 Reply Last reply
        1
        • Q Offline
          Q Offline
          Qu3Uk
          wrote on last edited by
          #7

          So I'm pretty sure you can't do what you're trying to do with TCP as NodeRed can't listen on a port multiple times. It seems to see it as two connections as opposed to one connection and accessing that connections input/output.

          I guess this might be a security thing because you could use NodeRed as a man in the middle and do all sorts.. which is what we're trying do it. Sit between the gateway and the controllers and do awesome stuff.

          I'm sure "To Vera" in your code @petewill needs to listen on the same port "From Vera" is however if you do this you'll only be able to connect to one of the nodes. Once connected the other node will throw a port in use error.

          Also I'm pretty sure it's using two connections to the MYS gateway which should be fine as mine seems to handle two connections but if your using nodeRed and have something else directly connected to the GW you may have problems.

          I was looking to have NR pretend to be an ethernet gateway and convert MQTT messages back and forth down a TCP connection. Seems it's not the tool for the job.

          petewillP 1 Reply Last reply
          0
          • Q Qu3Uk

            So I'm pretty sure you can't do what you're trying to do with TCP as NodeRed can't listen on a port multiple times. It seems to see it as two connections as opposed to one connection and accessing that connections input/output.

            I guess this might be a security thing because you could use NodeRed as a man in the middle and do all sorts.. which is what we're trying do it. Sit between the gateway and the controllers and do awesome stuff.

            I'm sure "To Vera" in your code @petewill needs to listen on the same port "From Vera" is however if you do this you'll only be able to connect to one of the nodes. Once connected the other node will throw a port in use error.

            Also I'm pretty sure it's using two connections to the MYS gateway which should be fine as mine seems to handle two connections but if your using nodeRed and have something else directly connected to the GW you may have problems.

            I was looking to have NR pretend to be an ethernet gateway and convert MQTT messages back and forth down a TCP connection. Seems it's not the tool for the job.

            petewillP Offline
            petewillP Offline
            petewill
            Admin
            wrote on last edited by
            #8

            @Qu3Uk Thanks for the reply. Did you try SOCAT at all? I was hoping that would help. I haven't had a chance to do anything with this recently though.

            My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

            Q 1 Reply Last reply
            0
            • petewillP petewill

              @Qu3Uk Thanks for the reply. Did you try SOCAT at all? I was hoping that would help. I haven't had a chance to do anything with this recently though.

              Q Offline
              Q Offline
              Qu3Uk
              wrote on last edited by
              #9

              @petewill

              No i didn't but I don't think I can. I run all my "things" nodered/controllers etc on separate Virtual Machines and communication is all over IP rather than serial/usb.

              Sitting on this for a bit see if I come up with anything.

              1 Reply Last reply
              0
              • tbowmoT Offline
                tbowmoT Offline
                tbowmo
                Admin
                wrote on last edited by
                #10

                @Qu3Uk, @petewill

                It should be possible to setup a socat socket converting the tcp stream into a virtual serialport, that could be used within NodeRed as a standard serial port in / out unit. I haven't tried that part yet though, as I'm not using a ethernet GW on my production system. I could set one up though, as I have a development version of the upcomming mysensors GW device (which also is ethernet enabled)

                I'll see if I can get the time to look into it, the comming days..

                Q petewillP 2 Replies Last reply
                0
                • tbowmoT tbowmo

                  @Qu3Uk, @petewill

                  It should be possible to setup a socat socket converting the tcp stream into a virtual serialport, that could be used within NodeRed as a standard serial port in / out unit. I haven't tried that part yet though, as I'm not using a ethernet GW on my production system. I could set one up though, as I have a development version of the upcomming mysensors GW device (which also is ethernet enabled)

                  I'll see if I can get the time to look into it, the comming days..

                  Q Offline
                  Q Offline
                  Qu3Uk
                  wrote on last edited by Qu3Uk
                  #11

                  @tbowmo Have to admit I didn't actually look in to socat (read: Google it).

                  Seems very possible. I'll have a play tonight.

                  1 Reply Last reply
                  0
                  • tbowmoT tbowmo

                    @Qu3Uk, @petewill

                    It should be possible to setup a socat socket converting the tcp stream into a virtual serialport, that could be used within NodeRed as a standard serial port in / out unit. I haven't tried that part yet though, as I'm not using a ethernet GW on my production system. I could set one up though, as I have a development version of the upcomming mysensors GW device (which also is ethernet enabled)

                    I'll see if I can get the time to look into it, the comming days..

                    petewillP Offline
                    petewillP Offline
                    petewill
                    Admin
                    wrote on last edited by
                    #12

                    @tbowmo said:

                    I'll see if I can get the time to look into it, the comming days..

                    That would be awesome! No hurry :)

                    My "How To" home automation video channel: https://www.youtube.com/channel/UCq_Evyh5PQALx4m4CQuxqkA

                    1 Reply Last reply
                    0
                    • Q Offline
                      Q Offline
                      Qu3Uk
                      wrote on last edited by
                      #13

                      So I had a go at using SOCAT and although it's working it doesn't seem to like multiple connections on the TCP port. Although it will accept the connection it seems to output data from Serial>Ethernet is a round robin kind of way.

                      Reason I had two connections to it was to ensure the pipe was always read as the other post it was mentioned if the pipe isn't cleared there would be memory problems and I noticed not all the data was getting to all the TCP connections..

                      Anyway here is the code if you want to check it out.

                      Socat

                      sudo socat PTY,link=/dev/ttyS81,mode=666,group=dialout,raw TCP-LISTEN:40501,fork,reuseaddr & 
                      sudo socat PTY,link=/dev/ttyS82,mode=666,group=dialout,raw TCP-LISTEN:40502,fork,reuseaddr &
                      

                      NodeRead

                      [{"id":"e9998a90.266cc8","type":"serial-port","z":"a89027d9.b1ef08","serialport":"/dev/ttyS82","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":true},{"id":"ee7d4fbe.58c5f","type":"serial-port","z":"a89027d9.b1ef08","serialport":"/dev/ttyS81","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":true},{"id":"50839f8a.fbcaa","type":"debug","z":"a89027d9.b1ef08","name":"Full-Debug","active":true,"console":"false","complete":"true","x":595,"y":575,"wires":[]},{"id":"d5b18044.18e1f","type":"tcp in","z":"a89027d9.b1ef08","name":"MYS-GW-OUT","server":"client","host":"192.168.1.150","port":"5003","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"MYS-GW-Output","base64":false,"x":103,"y":963,"wires":[["db05059b.37e4e8","4f3b7e79.739e6"]]},{"id":"c462686d.bb5a78","type":"catch","z":"a89027d9.b1ef08","name":"","scope":null,"x":387,"y":574,"wires":[["50839f8a.fbcaa"]]},{"id":"9fdda3da.86eb7","type":"debug","z":"a89027d9.b1ef08","name":"PayloadDebug","active":true,"console":"false","complete":"payload","x":584,"y":666,"wires":[]},{"id":"db05059b.37e4e8","type":"serial out","z":"a89027d9.b1ef08","name":"ControllerOne-Out","serial":"ee7d4fbe.58c5f","x":619,"y":875,"wires":[]},{"id":"75f6db75.bba3c4","type":"serial in","z":"a89027d9.b1ef08","name":"ControllerOne-IN","serial":"ee7d4fbe.58c5f","x":103,"y":894,"wires":[["6bbbe087.e897"]]},{"id":"6bbbe087.e897","type":"tcp out","z":"a89027d9.b1ef08","host":"192.168.1.150","port":"5003","beserver":"client","base64":false,"end":false,"name":"MYS-GW-IN","x":605,"y":949,"wires":[]},{"id":"4f3b7e79.739e6","type":"serial out","z":"a89027d9.b1ef08","name":"ControllerTwo-Out","serial":"e9998a90.266cc8","x":625,"y":1044,"wires":[]},{"id":"73b94814.883c88","type":"serial in","z":"a89027d9.b1ef08","name":"ControllerTwo-IN","serial":"e9998a90.266cc8","x":104,"y":1045,"wires":[["6bbbe087.e897"]]},{"id":"8121ed9b.ba597","type":"tcp in","z":"a89027d9.b1ef08","name":"ControllerOne-TCP-Out","server":"client","host":"127.0.0.1","port":"40501","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"","base64":false,"x":151,"y":731,"wires":[["9fdda3da.86eb7"]]}]
                      
                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      22

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.1k

                      Posts


                      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • MySensors
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular