Troubleshooting
When one Modbus TCP server can serve two clients
Short answer
One Modbus TCP server can serve two clients. The same server address and listening port work when the server implementation holds concurrent sessions and the CPU has free connection resources; a second server block on its own port is only for implementations that cannot hold both clients.
On this page
Yes, one Modbus TCP server can serve two clients. The protocol itself allows many concurrent TCP sessions against a single listening port, so an existing client does not block a historian that wants the same registers. What decides it is the server implementation and the CPU behind it: they must hold both sessions and still have free connection resources. Start by running the second client against the same server address and listening port the first client already uses. Add a second server block with its own port only when the installed implementation serves one client at a time, or when the CPU's connection resources are exhausted. This article gives the connection budget, the commissioning steps and the decision for each outcome you can observe at the server.
The protocol allows it; the CPU decides #
Modbus TCP is a plain client-server exchange over TCP. A client may hold many simultaneous TCP connections open at once, using a different local port for each, and a server address plus listening port identifies the service, not a client. Two clients reading the same register range therefore need no second copy of the data — they need two server-side sessions. Sharing an IP subnet gives the second client reachability; it does not create a session or reserve resources on the server.
On a Siemens CPU, the MB_SERVER instruction is what processes client connection requests over the TCP connection, so its configuration together with the CPU's connection pool sets the ceiling on how many clients the server can hold. Running that Modbus TCP service alongside the CPU's existing S7 communications through the same physical port is its own configuration question, and the article on one S7 CPU PN port carrying Modbus TCP and S7 communications together walks through it: https://imdhmi.com/articles/can-one-s7-cpu-pn-port-run-modbus-tcp-and-s7-comms-together/
Count the connection resources before you promise the second client #
Two documented numbers set the budget:
- On an S7-1200 integrated PROFINET interface, open user communication is limited to 8 connections, with 12 as the maximum depending on the CPU and its load.
- On S7-300 and S7-400 CPUs, a data transfer longer than 240 bytes occupies 2 connection resources in the CPU; counting the Modbus/TCP header, a register payload near that boundary can tip a single read into two resources.
Worked example on an S7-400-class CPU. The existing client reads 100 holding registers in one request: 100 × 2 bytes = 200 bytes of payload, at or below the boundary, so it occupies 1 connection resource. The historian reads 125 holding registers: 125 × 2 bytes = 250 bytes of payload, longer than the boundary, so it occupies 2 connection resources. Both clients together consume 3 connection resources for Modbus TCP.
The decision follows from the diagnostics: open the CPU's online connection diagnostics while both clients poll. If 3 or more connection resources are free, run both clients on the existing server instance and you are done. If fewer are free, cut the historian's registers per read back under the boundary — 120 registers × 2 bytes = 240 bytes, which still occupies 1 resource — or free a connection elsewhere before the historian can connect.
Add the historian without disturbing the working client #
- Record the working client's destination first: the server IP address, the TCP port, the unit identifier, the function codes, the register offsets and counts, and the data types. This is the reference the historian must match.
- Connect the historian host to the same industrial Ethernet network, assign it a unique IP address in that subnet, and check link status and switch-port errors before any protocol test.
- Configure the historian as a Modbus TCP client against the same server address and the same listening port. If the historian runs on a dedicated plant-floor box rather than a rack server, a fanless industrial mini PC is the typical host for that job: https://industrialmonitordirect.com/collections/all-mini-pc/
- Start read-only: keep write function codes out of the first configuration so that a mapping error cannot move a setpoint or issue a command to the process.
- Trigger the historian connection while watching the server's online diagnostics, and note whether the new session is accepted, refused, or displaces the existing one.
- Verify one known, changing process value end to end before expanding the point list, matching byte order, word order, signedness and scaling — a successful read can still decode into a wrong value. The logging configuration on the historian side then follows the same pattern as Modbus TCP data logging to a database from a plant PC: article:modbus-tcp-data-logging-to-a-database-from-a-plant-pc
When a second server port is actually needed #
A second listening port is not a general requirement for two clients; it is the fix for a specific case: the installed server block cannot hold concurrent connections, or its connection resources are exhausted and cannot be reallocated. Then configure a second server instance — a second instance of the server block — with its own MB Port value, 503 being the usual example. Changing the historian's destination port never creates the service on its own: the new instance must actually listen on that port, and every firewall and access rule on the path must permit it.
On a redundant CPU pair, adding a server block also touches the redundancy configuration, so plan that change with the redundancy documentation in hand and test both paths, not just the active one.
Separate the four outcomes you can observe #
- No TCP session completes: a transport or listener problem. Check the destination address, the destination port, the access rules on the path, and the free connection resources at the CPU.
- Connection refused with resources exhausted: the server has no free slot. Reduce the historian's registers per read or reallocate connections; changing a client-side port does not fix a server-side shortage.
- A Modbus exception comes back: the server received the request and rejected it. Read the exception code against the function code, register offset and register count in the request.
- A valid response with a wrong value: a mapping or decoding problem, not a connection problem. Fix the offset notation, data type, byte and word order and scaling.
The decision #
- The existing server block accepts concurrent sessions and the CPU shows the needed free connection resources: point both clients at the same server address and listening port — no new block, no new port.
- The installed block serves one client at a time: add a second server instance with its own MB Port, point the historian at that port, and permit it on the path.
- Connection resources are exhausted and cannot be reallocated: bring the historian's per-read payload under the transfer boundary so each read occupies one resource, or rework the acquisition architecture. Until one of these three states is confirmed in the server's own diagnostics, the second client is unproven — and a ping that answers proves IP reachability, nothing about a Modbus session.
Questions asked
Do the two clients need to poll at the same interval?
No. Each client holds its own TCP session and polls on its own schedule. What to watch is the server's response time under both poll loads together: if responses slow down after the historian starts, lengthen the historian's interval or split its register reads into smaller requests instead of assuming a fixed interval fits the CPU.
Does one client reading a register change what the other client reads?
No. A Modbus read neither consumes nor alters the register values, so the existing client keeps working unchanged. Each client samples at its own moment, though, so the two clients can see different snapshots of the same registers. If the historian needs one coherent set, it should request those registers in a single read and treat that one response as one sample.
Which port should the historian target when the server keeps its existing listener?
The same listening port the working client already targets, which is the standard Modbus TCP port 502 unless the plant deliberately changed it. The port number selects a TCP service at the server address; the historian cannot create the service, so it must point at a port the server application actually listens on and the network path permits.