# Can't send network variables to codesys

**URL:** <https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186>\
**Category:** General\
**Created:** [18 October 2022 06:52 UTC](https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186 "2022-10-18T06:52:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mossi92](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mossi92/32/60390_2.png) [@Mossi92](https://discourse.nodered.org/u/Mossi92)\
**Post date:** [18 October 2022 06:52 UTC](https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186/1 "2022-10-18T06:52:39Z")

</div>

Hi, I am struggeling with sending network variables to codesys.  
I am able to receive variables from PLC to Node-RED through node-red-contrib-nvl, but not the other way.

Node-RED V3.0.2 running on raspberry pi 4  
Codesys 3.5 running on Deif AMC300

```auto
[
    {
        "id": "0b0cedbd47c94c35",
        "type": "tab",
        "label": "Codesys UECC",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "1a6f5a728e9537a6",
        "type": "udp out",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "addr": "192.168.1.97",
        "iface": "",
        "port": "1202",
        "ipv": "udp4",
        "outport": "",
        "base64": false,
        "multicast": "false",
        "x": 1210,
        "y": 260,
        "wires": []
    },
    {
        "id": "e1d02d7d119a83c4",
        "type": "udp in",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "iface": "",
        "port": "1202",
        "ipv": "udp4",
        "multicast": "false",
        "group": "",
        "datatype": "buffer",
        "x": 160,
        "y": 160,
        "wires": [
            [
                "f79a36fe563603f9",
                "6cc11dd97326b7fd"
            ]
        ]
    },
    {
        "id": "f79a36fe563603f9",
        "type": "debug",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 490,
        "y": 100,
        "wires": []
    },
    {
        "id": "6cc11dd97326b7fd",
        "type": "nvl-receive",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "definition": "VAR_GLOBAL\n xBool: BOOL;\nEND_VAR",
        "listId": "1",
        "globaltypes": "e1676971a228cf35",
        "x": 490,
        "y": 160,
        "wires": [
            [
                "1585a99456d92050"
            ]
        ]
    },
    {
        "id": "1585a99456d92050",
        "type": "debug",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1170,
        "y": 160,
        "wires": []
    },
    {
        "id": "c38b0a5c0305d07e",
        "type": "nvl-send",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "definition": "VAR_GLOBAL\n xBool2 : BOOL;\nEND_VAR\n\n",
        "listId": "3",
        "globaltypes": "e1676971a228cf35",
        "x": 480,
        "y": 260,
        "wires": [
            [
                "1a6f5a728e9537a6",
                "f80ae7976c014aba"
            ]
        ]
    },
    {
        "id": "da042db614c37923",
        "type": "inject",
        "z": "0b0cedbd47c94c35",
        "name": "False",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "0",
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 170,
        "y": 220,
        "wires": [
            [
                "b2bf3a6572586bf4"
            ]
        ]
    },
    {
        "id": "dfe07dd340b0d084",
        "type": "inject",
        "z": "0b0cedbd47c94c35",
        "name": "True",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "1",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 170,
        "y": 260,
        "wires": [
            [
                "b2bf3a6572586bf4"
            ]
        ]
    },
    {
        "id": "f80ae7976c014aba",
        "type": "debug",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 690,
        "y": 320,
        "wires": []
    },
    {
        "id": "b2bf3a6572586bf4",
        "type": "function",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "func": "const bool = msg.payload;\n\nmsg.payload = {\n \"xBool2\": bool\n}\n\nreturn msg;\n\n// {\n// \"xBool\": true,\n// }",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 320,
        "y": 260,
        "wires": [
            [
                "c38b0a5c0305d07e",
                "6e0a73a3f78cb3ae"
            ]
        ]
    },
    {
        "id": "6e0a73a3f78cb3ae",
        "type": "debug",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 490,
        "y": 320,
        "wires": []
    },
    {
        "id": "e1676971a228cf35",
        "type": "nvl-datatypes",
        "name": "",
        "datatypes": ""
    }
]

```

Send Node:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/2360caea41af4b8bffeff8580f757ae3a33500ee.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/8/18dd9feb15809520518cf934b686e16e6ed3a90c.png)

Network variables list (receiver):  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/4/c444f2d1fd26801f89224ddc39488419590fd176.png)

---

<div class="post-metadata">

**Author:** ![Hopperpop](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hopperpop/32/42533_2.png) [@Hopperpop](https://discourse.nodered.org/u/Hopperpop)\
**Post date:** [18 October 2022 20:56 UTC](https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186/2 "2022-10-18T20:56:52Z")

</div>

Hello Mossi,

Did you try by temporally disabling your firewall on de CodeSys device? Is it also possible to share the full receiver configuration in CodeSys (or the imported file)?

---

<div class="post-metadata">

**Author:** ![Mossi92](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mossi92/32/60390_2.png) [@Mossi92](https://discourse.nodered.org/u/Mossi92)\
**Post date:** [19 October 2022 12:34 UTC](https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186/3 "2022-10-19T12:34:59Z")

</div>

Hi Hopperpop,

do you mean the network firewall or on the codesys device? Cant seem to find a firewall on the device..

```auto
<GVL>
  <Declarations><![CDATA[{attribute 'qualified_only'}
VAR_GLOBAL
    xBool2: BOOL;
END_VAR]]></Declarations>
  <NetvarSettings Protocol="UDP">
    <ListIdentifier>3</ListIdentifier>
    <Pack>True</Pack>
    <Checksum>False</Checksum>
    <Acknowledge>False</Acknowledge>
    <CyclicTransmission>True</CyclicTransmission>
    <TransmissionOnChange>True</TransmissionOnChange>
    <TransmissionOnEvent>False</TransmissionOnEvent>
    <Interval>T#5000ms</Interval>
    <MinGap>T#20ms</MinGap>
    <EventVariable>
    </EventVariable>
    <ProtocolSettings>
      <ProtocolSetting Name="Broadcast Adr." Value="255.255.255.255" />
      <ProtocolSetting Name="Port" Value="1202" />
    </ProtocolSettings>
  </NetvarSettings>
</GVL>

```

---

<div class="post-metadata">

**Author:** ![Hopperpop](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hopperpop/32/42533_2.png) [@Hopperpop](https://discourse.nodered.org/u/Hopperpop)\
**Post date:** [19 October 2022 18:59 UTC](https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186/4 "2022-10-19T18:59:35Z")

</div>

I was indeed referring to the firewall on the codesys device. It's always possible that the firewall is blocking incoming traffic and allowing outgoing. Although if it works with another controller/plc it should be fine.

I have imported your flow and GVL into a codesys project. Changed the IP-adress of the udp sender node to the one of my controller, and everything works fine. Can you double check if your IP-adress is set correctly to the one of the controller in the udp node?

---

<div class="post-metadata">

**Author:** ![Mossi92](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mossi92/32/60390_2.png) [@Mossi92](https://discourse.nodered.org/u/Mossi92)\
**Post date:** [20 October 2022 10:22 UTC](https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186/5 "2022-10-20T10:22:21Z")

</div>

Not sure where I can find this setting on the PLC.  
Waiting for answer from the supplier.  
I'll update as soon as I get it.

The IP is correct. I have logged in to the web interface for the controller with the IP I use in Node-RED.

---

<div class="post-metadata">

**Author:** ![Mossi92](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mossi92/32/60390_2.png) [@Mossi92](https://discourse.nodered.org/u/Mossi92)\
**Post date:** [20 October 2022 12:56 UTC](https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186/6 "2022-10-20T12:56:35Z")

</div>

Thank you for the help @Hopperpop.

The firewall was the problem!

For anyone else facing this in the future:  
temporarily disable firewall with these commands in cmd or login with PuTTy.

```auto
SSH admin@AMC300.local
 sudo su
 sudo nft flush ruleset

```

---

<div class="post-metadata">

**Author:** ![Hopperpop](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hopperpop/32/42533_2.png) [@Hopperpop](https://discourse.nodered.org/u/Hopperpop)\
**Post date:** [20 October 2022 20:31 UTC](https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186/7 "2022-10-20T20:31:58Z")

</div>

Great to hear that. But only fully disable the firewall to test and see if it's causing the issue. Keeping it enabled and adding a rule for all incoming traffic on port 1202, is the proper solution!

---

<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 2022 20:32 UTC](https://discourse.nodered.org/t/cant-send-network-variables-to-codesys/69186/8 "2022-11-03T20:32:00Z")

</div>

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