IMD SolutionComputing LibraryShop main store

Troubleshooting

Node-RED on IOT2050 shows Client Not Ready To Read At State init

Edge computing and IIoT Published 5 min read By IMD Solution engineering team

Short answer

The error means the read fired while the Modbus client was still initializing, so its TCP connection to the simulator never opened. On a direct cable from the IOT2050 to a Windows laptop, the two causes are Windows Firewall dropping inbound TCP 502 and a simulator running as a client instead of a listening server. Prove the path with a port test, then fix the flow.

A monitor showing a flow editor with wired nodes, beside a keyboard and a small fanless edge computer
On this page
  1. What the init state is telling you
  2. Client and server roles on this cable
  3. The causes, in the order to check them
  4. Checking the IP plan for 192.168.200.1 and 192.168.200.5 on the X1 P1 cable
  5. Verifying the path before you edit the flow
  6. Opening TCP 502 on the Windows laptop
  7. If the error stays after the port is open
  8. Questions asked

The error Error: Client Not Ready To Read At State init means your read fired while the Modbus client was still initializing: its TCP socket to the simulator never opened. Nothing is wrong with your registers or your flow logic. On a direct cable from the IOT2050's X1 P1 port to a Windows laptop running a Modbus simulator on TCP port 502, two causes cover almost every case: Windows Firewall silently dropping the inbound connection to the laptop, and the simulator running as a client instead of a listening server. Verify the TCP path first, then edit the flow.

What the init state is telling you #

The message comes from the Modbus client state machine inside node-red-contrib-modbus, which wraps the modbus-serial library. The init state means the client object exists but its socket has not opened. Any modbus-flex-getter or Modbus Read triggered in that state returns exactly this error. The project's own issue tracker describes it the same way: a read was issued without waiting for the connection.

So treat it as a connection fault, not a data fault. A wrong Unit-ID or a bad register address produces a timeout or a Modbus exception response instead, not an init-state error.

Client and server roles on this cable #

Modbus TCP has one role that dials out and one that listens. The old terms were master and slave; the current terms are client and server:

  • The IOT2050 running Node-RED is the Modbus TCP client. It opens the TCP connection and sends the requests. This is the same role it takes whenever it reads PLC data over OPC UA, MQTT or Modbus.
  • The laptop with the simulator is the Modbus TCP server. It listens on port 502 and answers. The product name "Modbus Slave" is historical; in this setup it must run in server, listen mode.

The direction is fixed: the client always connects to the server's port 502. A simulator set to connect to a remote host will never work here, because nothing on the cable is listening for it.

The causes, in the order to check them #

  1. Windows Firewall dropping inbound TCP 502. The default profile blocks unsolicited inbound connections, and the gateway's outbound connection is inbound traffic to the laptop. This is the most common cause on this exact setup.
  2. Simulator in connect mode, or bound to the wrong interface. It must listen, on the laptop's wired Ethernet address, with Wi-Fi off so replies route over the cable.
  3. First trigger fired before the client connected. A read injected at deploy can land while the client is still in init. A short delay before the first trigger fixes this case, and only this case.
  4. Wrong host in the client configuration, or a duplicate address on the link. Two devices answering the same address create an ARP conflict, and the connection attempt times out.

Checking the IP plan for 192.168.200.1 and 192.168.200.5 on the X1 P1 cable #

Inputs. The IOT2050's X1 P1 port holds its factory-default address, 192.168.200.1. The laptop's Ethernet adapter was set to 192.168.200.5. Both use the subnet mask 255.255.255.0, which leaves 24 network bits and 8 host bits.

Rule. Two hosts on a direct cable with no router can only talk when their addresses fall in the same subnet after the mask is applied.

Arithmetic. Apply the mask to each address:

  • 192.168.200.1 AND 255.255.255.0 = 192.168.200.0
  • 192.168.200.5 AND 255.255.255.0 = 192.168.200.0

The usable host range in that subnet is 2^8 − 2 = 254 addresses, 192.168.200.1 through 192.168.200.254, so both addresses are valid and distinct.

Result. Both devices sit in the same subnet, so no gateway is needed on the cable and a ping must succeed.

Decision. If the two masked results had differed, you would rewrite both addresses into one subnet before any port test. Here they match, so if ping passes and the Modbus read still fails, the fault is above the IP layer: the port or the simulator, never the addressing.

Verifying the path before you edit the flow #

Run these in order and stop at the first failure:

  1. From the IOT2050 console: ping -c 4 192.168.200.5. Four replies confirm the cable and the IP plan.
  2. From the same console: nc -vz 192.168.200.5 502. A succeeded! result means the TCP path to the simulator is open and the problem is inside your Node-RED configuration. A Connection refused or a hang means the firewall or the simulator, not Node-RED.
  3. On the laptop, in PowerShell: Test-NetConnection -ComputerName 192.168.200.5 -Port 502. The line to look for is TcpTestSucceeded : True.

On a fresh Windows laptop with no firewall rule, step 2 hangs and step 3 returns False while step 1 passes. That pattern is the firewall, and the next section is the fix.

Opening TCP 502 on the Windows laptop #

Open PowerShell as administrator and create one inbound allow rule:

New-NetFirewallRule -DisplayName "Modbus TCP 502 Inbound" -Direction Inbound -Protocol TCP -LocalPort 502 -Action Allow -Profile Any

Keep -Profile Any: a direct cable usually lands in the Public profile, and a rule scoped to Private only will not match it. Then re-run Test-NetConnection from step 3 above; when it returns True, the port is open. Start the simulator in server mode on the laptop's Ethernet address, load the holding registers, set its Unit-ID to match the client configuration, and re-deploy the flow.

If the error stays after the port is open #

  • Swap the flex-getter for a Modbus Read node on the same client configuration. Both failed identically here, which confirms the fault is below the node level.
  • Try a different simulator. In this exact setup, pyModSlave in server mode worked after the first tool did not, with the Modbus Read node reading data normally.
  • Turn off the laptop's Wi-Fi so the simulator binds and replies on the wired interface.
  • Put a short delay before the first trigger so the client finishes connecting before the first poll.
  • Once reads run but a getter stops after an error, that is a different failure: one failed Modbus getter freezing the next getter in Node-RED.

The decision for this case: the gateway keeps its default address and stays the client, the laptop listens as the server on port 502 behind an explicit firewall rule, and nc -vz from the gateway console is the test that proves it before any flow is changed.

Questions asked

Does the init error mean node-red-contrib-modbus is broken?

No. The message is the Modbus client's state machine reporting that a read was triggered while the client was still in its init state, before the TCP socket opened. When the flex-getter and the Modbus Read node both return it from the same client configuration, the fault is in the connection path, not in the nodes.

Why did ping succeed while the Modbus read failed?

ICMP echo requests pass Windows Defender Firewall by default, while unsolicited inbound TCP on port 502 does not. A successful ping proves the cable, the addresses and the subnet, but says nothing about the port. Only a test that completes the TCP handshake, such as nc or Test-NetConnection on port 502, proves the simulator is reachable.

Can I prove the simulator is listening without a second device?

Yes. On the laptop, run Test-NetConnection against the loopback address 127.0.0.1 on port 502. Loopback traffic bypasses the firewall profiles, so a true result proves the simulator is bound and listening. If loopback succeeds but the same test against the laptop's Ethernet address fails, the firewall rule is what is missing.

Will a start delay on the getter fix the error by itself?

Only in one case: when the first trigger fires at deploy before the client configuration node finishes connecting. If the port test to the simulator fails, no delay helps, because the connection never opens. Add the delay after the TCP path is proven, so the client connects before the first poll.

Keep reading

  • Comparison

    How Node-RED reads PLC data: OPC UA, MQTT or Modbus

    Pick the protocol by what the controller already serves, in this order: OPC UA if the PLC runtime exposes an OPC UA server, MQTT if the application can publish through an MQTT client library, Modbus TCP when only a register map exists. Node-RED has a client for all three; the deciding side is the PLC.

    Edge computing and IIoT

  • How-to

    Modbus TCP from a third-party PLC to cloud MQTT on IOT2040

    Yes. Modbus TCP has no vendor lock: any PLC that runs a Modbus TCP server on port 502 can be polled by an IOT2040, whatever its maker. One Modbus client node in Node-RED reads the PLC on X1 and one MQTT out node publishes on X2 to the broker over TLS on port 8883; OPC UA is needed only if the PLC itself runs an OPC UA server.

    Edge computing and IIoT

  • Explainer

    Why a C TCP socket cannot open a Node-RED WebSocket session

    A TCP connect to Node-RED on port 1880 proves the socket layer only. The WebSocket session opens after the C client sends an HTTP opening handshake that requests the endpoint path with the Upgrade headers, and payloads must then ride in masked protocol frames. Configure a C WebSocket library with host, port and path; appending the path to the address passed to inet_addr cannot work.

    Edge computing and IIoT

Why ArchestrA Historian storage shows high CPU usage