OMRON FINS Node-RED TypeError: self.socket.connect Fix

James Nishida12 min read
HMI / SCADAOmronTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

OMRON FINS Node-RED TypeError: self.socket.connect is not a function — Root Cause and Fix

Severity: Critical. Communication with OMRON CS1G/H, CJ1/CJ2, CP1, NX102 and NX1P PLCs via the node-red-contrib-omron-fins node is completely blocked. The FINS UDP socket never opens and the TCP path raises a secondary TypeError: buf.readUint32BE is not a function.

This reference documents the exact failure mode seen on the Siemens SIMATIC IOT2050 running its pre-installed Node-RED image, the underlying Node.js 10.23.1 dgram library deficiency that causes the self.socket.connect error, the secondary readUint32BE failure on the TCP transport, and the verified remediation path that restores FINS polling against an OMRON CS1G-CPU PLC.

1. Problem Description

Engineers deploying Node-RED as a gateway between a factory network and an OMRON PLC (CS1G, CS1H, CJ1M, CJ2M, CP1E, CP1L, NX102-9000, NX1P) on a Siemens IOT2050 see one of the following runtime errors the moment an inject payload is delivered to a node-red-contrib-omron-fins FINS node:

Transport Symptom Error String
UDP (default) Node shows red dot, no traffic on Wireshark TypeError: self.socket.connect is not a function
TCP (workaround attempt) TCP socket opens, first inject times out TypeError: buf.readUint32BE is not a function

Both errors originate inside the FINS node and are not network faults. Switching from UDP to TCP does not resolve the underlying issue and merely exposes a second symptom of the same root cause: the Node.js runtime shipped on the IOT2050 image is too old.

2. Affected Versions and Environment

Component Reported Version Status
Node.js v10.23.1 End-of-life since 2021-04-30 (Node.js 10 LTS line)
Node.js (Siemens newer image) v12.22.5 EOL 2022-04-30 but sufficient for the FINS node
Node-RED 1.2.7 Legacy, supported on Node 12+
node-red-contrib-omron-fins 0.5.0 Node.js >= 12 required
Gateway hardware Siemens SIMATIC IOT2050 (6ES7647-0BA00-0YA2) Debian-based industrial IoT gateway
PLC family OMRON CS1G-CPU (CS1G-CPU42H/43H/44H/45H) Refer to SYSMAC CS Series CS1G/H-CPU Operation Manual (W339)
Critical observation: The IOT2050 ships with Node-RED pre-installed under /usr/lib/node_modules. Performing apt upgrade or an npm install -g does not overwrite the bundled image. Two parallel Node.js and Node-RED trees coexist. The remediation must target the user-scope install at /home/root/.node-red and use a curated upgrade script that replaces the image-default Node.js.

3. Root Cause Analysis

The error string self.socket.connect is not a function is a deterministic failure of the Node.js dgram module. In Node.js 10 the UDP socket returned by dgram.createSocket({type:'udp4'}) exposes only send(buffer, offset, length, port, address, callback) and not the connect(port, address, callback) method that node-red-contrib-omron-fins v0.5.0 calls immediately after creating the socket to set the default peer.

The dgram.Socket.prototype.connect method was added in Node.js 12.0.0. Any code path that uses udp4/udp6 with the connected-UDP pattern is silently broken on Node 10:

  • Node 10: dgram socket is connectionless only; socket.connect is undefined.
  • Node 12.0.0+: dgram.Socket.prototype.connect() implemented (see Node.js 12 changelog).
  • Node 12.22.5: confirmed working — UDP FINS polls complete and readUint32BE on the response buffer is available (introduced in Node 4 but exposed only through the global Buffer namespace which the FINS node imports via require('buffer').Buffer — Node 10 ships an older prototype chain on some Debian ARM builds).

The TCP variant's TypeError: buf.readUint32BE is not a function is a downstream consequence: the FINS node allocates a Buffer from a buffer pool created by the older runtime, then attempts to use Buffer.prototype.readUint32BE. On some Node 10 builds distributed with industrial Debian images the prototype methods are missing on pooled Buffer instances created by the embedded C++ binding.

4. Why Switching to TCP Does Not Work

The instinct to bypass the UDP error by selecting the TCP protocol selector in the FINS node configuration is logical but incorrect in this environment. Even with a successful TCP three-way handshake (SYN, SYN-ACK, ACK visible in Wireshark against TCP/9600), the first FINS read command raises:

TypeError: buf.readUint32BE is not a function

followed by a connection timeout when the PLC closes the half-open socket. The error is again produced by the Node.js runtime, not by the PLC. The OMRON FINS/TCP server (port 9600) is fully compliant and is returning valid FINS responses — the client simply cannot parse them.

Rule of thumb: If the FINS node throws a TypeError whose message references socket or Buffer prototype methods (connect, readUint32BE, writeUInt32BE), the failure is a Node.js version problem, not a network, firewall, or PLC problem. Check node -v first.

5. Solution Path A — Upgrade Node.js to v12 LTS (Recommended)

The official Node-RED Linux installer script published by the Node-RED project supports Debian-based ARM devices including the SIMATIC IOT2050. It performs a clean replacement of the bundled Node.js, removes the obsolete image-default installation, and re-anchors node, npm, and node-red into /usr/bin.

5.1 Prerequisites

  • SSH or serial-console root access to the IOT2050 (default user root).
  • Outbound HTTPS (TCP/443) to raw.githubusercontent.com and deb.nodesource.com.
  • At least 600 MB free on the root filesystem (Node 12 + Node-RED + build toolchain).
  • Backup of the existing flows: cp /home/root/.node-red/flows_*.json /tmp/.

5.2 Step-by-Step Upgrade

  1. Install the build toolchain and prerequisites:
    apt install -y build-essential git curl bash ca-certificates
  2. Stop the system Node-RED service to release port 1880:
    systemctl stop nodered.service
  3. Run the Linux installer with an explicit Node major version to avoid the image-default Node 10 being reused:
    bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node14
  4. Verify the new binary:
    node -v → expect v14.x.y or v16.x.y
    npm -v → expect 6.x or higher
    which node → must resolve to /usr/bin/node
  5. Rebuild native modules against the new Node ABI:
    cd /home/root/.node-red
    npm rebuild
  6. Reinstall the FINS node (the upgrade may invalidate the prior symlink):
    cd /home/root/.node-red
    npm install node-red-contrib-omron-fins
  7. Start Node-RED and validate:
    systemctl start nodered.service
    node-red logs -f

5.3 Why --node14

Node 14 is the lowest actively maintained LTS at the time of the Siemens IOT2050 image release cycle and the lowest version where dgram.Socket.prototype.connect and the modern Buffer prototype chain are guaranteed. Node 12.22.5 is the absolute minimum and works, but is itself end-of-life. Node 16 LTS is acceptable and brings a hardened Buffer allocation path.

6. Solution Path B — Siemens Image Update to Node 12.22.5

Siemens has republished the IOT2050 example image with Node.js 12.22.5 bundled. If the application cannot tolerate any downtime from a manual Node upgrade, reflashing the device with the newer image is the lower-risk option:

  1. Download the latest IOT2050 example image from the Siemens Industry Online Support portal (article ID 109769802).
  2. Write the image to a USB stick or SD card and boot the IOT2050 into recovery mode.
  3. Flash the device and re-import the prior flows_*.json and flows_cred.json files.
  4. Reinstall the FINS node: cd /home/root/.node-red && npm install node-red-contrib-omron-fins
  5. Restart and confirm node -v reports v12.22.5 or higher.
Do not run npm install -g n and n stable on the IOT2050. The n package overwrites the binary at /usr/local/bin/node but the IOT2050 systemd unit hard-codes /usr/bin/node. The service silently continues to launch the old binary and the user concludes the upgrade did nothing.

7. FINS Node Configuration Reference

Once the runtime is corrected, configure the omron-fins node with the parameters below. The values map to the OMRON FINS header and transport selector fields.

Field Recommended Value Notes
Name Free text (e.g. CS1G-Line1) Identifies the node in the flow.
Protocol UDP (recommended) or TCP UDP delivers lower latency; TCP is required when traversing NAT or stateful firewalls.
Host IP PLC IP, e.g. 192.168.250.1 Must match the CS1W-ETN21 module's IP.
Port 9600 Default FINS UDP/TCP port. CS1G/H uses 9600 for both transports.
Local Node (PC) 0 — 254 FINS node address of the gateway. The PLC's ETN21 routing table must contain this value.
PLC Node 0 — 254 FINS node address of the CPU. CS1G-CPU defaults to 1.
Memory Area DM / CIO / WR / HR / AR / EM Word area selector. DM is the canonical scratch area (D00000–D32767).
Address 0 — 32767 Word offset within the selected area.
Count 1 — 500 Number of consecutive words to read. Cap at 500 for legacy CS1.
Return Format Buffer / String / Number / Array Selects how msg.payload is shaped downstream.

7.1 FINS Command Reference

The node constructs the following FINS command codes internally. They are listed here for engineers instrumenting the wire with Wireshark or tcpdump:

Operation Command (hex) Sub-command
Memory Area Read 01 01
Memory Area Write 01 02
Memory Area Fill 01 04
Multiple Memory Area Read 01 04 (multi-area variant)
Run / Stop CPU 04 01
CPU Unit Status Read 06 01
Cycle Time Read 06 20

8. OMRON CS1G PLC Network Setup

For the FINS node to bind successfully, the CS1W-ETN21 (or CS1W-EIP21) Ethernet module on the CS1G CPU must be configured with a consistent FINS node number and IP address. The procedure is documented in the SYSMAC CS Series CS1G/H-CPU Operation Manual (W339); the salient parameters are:

  1. In CX-Programmer, open the IO Table and Unit Setup for the CPU rack.
  2. Select the ETN21 unit (slot 0 typically) and click the Setup tab.
  3. Set IP Address to a static address in the same subnet as the IOT2050, e.g. 192.168.250.1/24.
  4. Set Subnet Mask to 255.255.255.0.
  5. Set FINS Node No. to a unique value in the range 1–254. CS1G default is 1.
  6. In Routing Table, add a local network entry: Network 0, Node 1, Relay 0.0.0.0.
  7. Add a remote network entry pointing to the IOT2050's FINS node: Network 0, Node <gateway>, Relay 192.168.250.10.
  8. Transfer the setup to the PLC and cycle power.

9. Verification

After the Node.js upgrade and node reinstall, validate the FINS communication in three layers:

9.1 Layer 1 — Process-level

Confirm Node-RED is running on the new binary:

ps -ef | grep node | grep -v grep

The first column of the matched line should resolve to /usr/bin/node, not /usr/lib/node_modules/node-red/red.js invoked by the image-default Node 10.

9.2 Layer 2 — Function-node smoke test

Drop a function node upstream of the FINS read and emit a heartbeat payload on every inject:

msg.payload = { ts: Date.now(), area: 'DM', addr: 0, count: 1 };
return msg;

If the omron-fins node shows the green connected ring and a debug payload is emitted downstream with a numeric msg.payload, the FINS read succeeded.

9.3 Layer 3 — Wire-level

Capture the FINS exchange on the IOT2050 interface:

tcpdump -i eth0 -nn -X udp port 9600

Expect a request frame with ICF=80, RSV=00, GCT=02, DNA=00, DA1=01, DA2=00, SNA=00, SA1=<gateway>, SA2=00, SID=00 and a response frame with the same SID, the data block, and MRES=00 00 end code. A non-zero MRES indicates a PLC-side rejection; consult the CS1G manual error code table.

10. Troubleshooting Matrix

Observed Error Likely Cause Resolution
self.socket.connect is not a function Node.js 10 dgram missing connected-UDP support Upgrade to Node 12+ via Linux installer with --node14
buf.readUint32BE is not a function Pooled Buffer prototype chain corruption on Node 10 ARM Upgrade to Node 12+; do not patch the Buffer object
Node-RED dashboard unreachable on port 1880 after upgrade Old systemd unit points to obsolete Node path Re-run Linux installer; the script regenerates the unit file
FINS node shows red dot, no error in console ETN21 routing table missing remote node entry Add gateway FINS node to PLC routing table (Section 8)
Wireshark shows FINS request but no reply Windows firewall on the PLC programming port or FINS/UDP blocked Verify PLC IP responds to ICMP; check router ACL on UDP/9600
Connection drops every 30–60 seconds FINS keep-alive mismatch between client and ETN21 Set ETN21 Server Keep-Alive > 60 s
Works in studio, fails on IOT2050 only Image-default Node 10 retained in /usr/lib Confirm which node resolves to /usr/bin/node

11. Alternative Controllers and Forward Compatibility

The node-red-contrib-omron-fins node supports the full FINS address family and is therefore also compatible with:

  • CJ1M-CPU with CJ1W-ETN21 — same FINS header and port 9600.
  • CJ2M-CPU3x with built-in EtherNet/IP — FINS reachable via 192.168.250.x; the CPU's IP is the FINS endpoint.
  • CP1L-EM with CP1W-CIF41 option board — FINS over TCP at 9600.
  • NX102-9000 and NX1P2-9Bxx — FINS over EtherNet/IP using UDP/9600; ensure the Sysmac Studio routing table includes the IOT2050 FINS node.
  • NX701-17xx — same FINS framing; performance headroom is essentially unlimited.

For the NX/NJ series, OMRON recommends the EtherNet/IP CIP path for high-throughput data and the FINS path for legacy HMI/ SCADA compatibility. The node-red-contrib-omron-fins node should not be used in the same flow as node-red-contrib-cip to avoid concurrent socket pressure on the controller's task budget.

12. Long-Term Maintenance Recommendations

  • Track Node.js LTS releases; Node 18 and Node 20 LTS are the current supported production lines as of 2024.
  • Schedule a reflash of the IOT2050 example image annually to keep the runtime current.
  • Pin node-red-contrib-omron-fins to a known-good version (0.5.0 at time of writing) using package-lock.json.
  • Monitor the Node-RED log for deprecation warnings on the FINS node; major version bumps may break the FINS framing.
  • Document the FINS node numbers, IP addresses, and memory-area map in the project's README for handoff.

What causes the TypeError: self.socket.connect is not a function in node-red-contrib-omron-fins?

The error is produced when the Node.js runtime is older than v12.0.0. The dgram module in Node 10 does not expose dgram.Socket.prototype.connect, which the FINS node calls immediately after creating the UDP socket. Upgrade Node to v12.22.5 minimum (v14 LTS recommended) and run npm rebuild in /home/root/.node-red.

Does switching the FINS node from UDP to TCP fix the error?

No. On Node 10 the TCP path produces a secondary error, TypeError: buf.readUint32BE is not a function, when the FINS node attempts to parse the response buffer. The failure is in the Node.js runtime, not the transport. The remediation is the same Node.js upgrade regardless of transport selection.

Why does the IOT2050 keep using the old Node 10 even after npm install -g n && n stable?

The n package installs the new binary at /usr/local/bin/node, but the IOT2050 systemd unit for Node-RED hard-codes /usr/bin/node. The service silently launches the image-default Node 10. Use the official Linux installer script with the --node14 flag, which rewrites both the binary path and the systemd unit.

What is the default FINS port for an OMRON CS1G-CPU with a CS1W-ETN21 module?

Both FINS/UDP and FINS/TCP use port 9600. The ETN21 also exposes a CIP/EtherNet/IP path on port 44818 and an HTTP configuration interface on port 80. See the SYSMAC CS Series CS1G/H-CPU Operation Manual (W339) for the full port and routing table reference.

Can the same flow read from both a CS1G and an NX102 with node-red-contrib-omron-fins?

Yes, as long as each PLC has a unique IP and FINS node number, and the IOT2050's FINS node number is registered in both controllers' routing tables. Place each FINS node on a separate UDP/TCP socket by giving each its own flow tab to simplify error isolation.

Is Node.js 10 still supported?

No. Node 10 reached end-of-life on 2021-04-30 and receives no security updates. Any IOT2050 image shipping Node 10 must be reflash or upgraded using the official Linux installer with the --node14 flag at minimum.

Back to blog