IMDHMIControls LibraryShop main store

Troubleshooting

Why a KV8000 register read fails with destination closed on a UR5e

Industrial networks Published 7 min read By IMDHMI controls team

Short answer

Destination closed after a successful connect means the robot's Modbus server accepted the TCP session and then refused the request bytes or the address in them. A Read Holding Registers request is 12 bytes with an MBAP length field of 6 and no CRC, and its address bytes must carry the robot's documented register number, 128 to 255 for general purpose, with no client-side 4000 shift reaching the wire.

On this page
  1. What the error does and does not say
  2. Rule out the path and the endpoint
  3. Read the capture in order
  4. Check the request frame byte by byte
  5. Check the address field against the robot's register map
  6. The fix for each capture result
  7. Prove the read with a known value
  8. Questions asked

Communication Destination Closed after a successful connect is a request fault wearing a network error's clothes. The open socket already proves the cable path, both IP addresses and the destination port, because the robot's Modbus server does not look at Modbus bytes until the first payload arrives, and a frame it cannot parse, or an address outside its map, can end the session with no reply at all. Work in this order: capture the first exchange, check the request against the Modbus TCP format, where a Read Holding Registers request is 12 bytes with an MBAP length field of 6 and no CRC, then check the two address bytes against the robot's register map, which the server applies exactly as sent. Two faults cover most of these cases: a malformed frame, or a client-side data-model shift that reached the wire.

What the error does and does not say #

The PLC message is a transport status: the TCP session ended after it was established. It names no register, no function code and no Modbus exception, so on its own it cannot tell you whether the robot refused the bytes or never answered them. Three actors can end the session: the robot's server closing the socket, an intermediary such as a firewall or a router rewriting the connection, or the PLC's own logic giving up on a timeout and tearing the socket down. A capture tells the three apart, so until you have one, leave the register numbers alone.

Rule out the path and the endpoint #

Spend two minutes here before any protocol work:

  • Link status at the PLC port and at the robot, plus the error counters on any switch port between them. A link that drops or retrains during the read sends you back to cabling first.
  • Destination address and port. The robot's Modbus server listens on the standard Modbus TCP port, 502. A connection to some other service on the same robot also completes its handshake, then closes as soon as Modbus bytes arrive, which produces exactly this error.
  • One connection with one request outstanding during diagnosis, so transaction identifiers and buffers stay observable in the trace.
  • A capture point where both directions are visible, a switch mirror port for example, running from before the handshake through the closure.

Read the capture in order #

  1. Mark the handshake and confirm the remote address and port belong to the robot's Modbus endpoint, not another service.
  2. Find the first payload the PLC sends.
  3. Look for any reply before the close.
  4. Note which side sends the close or reset, and the interval between request and close.
Trace result Meaning Next
Robot closes right after the request bytes, no reply The frame or the service is wrong Check the request bytes
Robot answers with a Modbus exception The frame parsed; the address or the span was refused Fix the address field or the quantity
PLC closes after a fixed delay with no reply A client timeout ended the session Compare the timeout with the measured reply time
Retransmissions or a link drop come first Delivery failed before Modbus Return to the path

An exception reply is progress: the server parsed the frame, so the header and the function code are right and the fault sits in the data. The case where a read runs off the end of a map into a gap is covered in Modbus exception 02 when a read crosses a register map gap.

Check the request frame byte by byte #

The format comes from the Modbus Messaging Implementation Guide for TCP/IP. A Read Holding Registers request, function 03, is 12 bytes: a 7-byte MBAP header followed by a 5-byte PDU. The header carries the transaction identifier (2 bytes), protocol identifier 0x0000 (2 bytes), a length field (2 bytes) and the unit identifier (1 byte). The length field counts every byte after it, so here it is the unit byte plus the PDU: 1 + 5 = 6. The PDU is the function code 0x03, the start address (2 bytes) and the quantity (2 bytes).

Faults that close the socket instead of drawing a reply:

  • A serial-style frame, slave address, function, data, CRC, sent straight down the socket. The server finds no valid header.
  • An RTU CRC trailer on the end. Modbus TCP has no checksum of its own beyond TCP, and the extra bytes corrupt the length accounting and the parse of whatever follows.
  • A length field that disagrees with the bytes after it. The server waits for bytes that never come, or slices the stream at the wrong boundary; how Modbus TCP framing depends on the MBAP length field goes deeper on that failure.
  • Byte-swapped fields. An address of 0x8000 instead of 0x0080 names a different register, and a swapped quantity can leave the legal range.
  • More bytes on the wire than the length field declares, from a transmit buffer longer than the request.

A raw socket builds none of this for you. Either the installation's Modbus instruction supplies the framing, or your PLC logic must write exactly these bytes.

Check the address field against the robot's register map #

The robot's map documents its general purpose registers at 128 to 255, and its server applies the address in the request as that documented number: protocol address and map number are the same, with no offset on the server side. The shift lives in clients. Some let you type data-model style numbers and strip them back off before transmitting; the common convention is 4000, so an entry of 4128 stands for register 128. Others transmit the entry unchanged. The advice to add 4000 is about the client, and it is wrong for a client that already sends what you type. Other masters carry the same family of conventions in the other direction, for example why Modbus error 8189 needs 400001 added to the register address.

Worked example, a read of one register at the first general purpose address:

00 01 00 00 00 06 01 03 00 80 00 01

  • Bytes 1-2: transaction identifier 0x0001, echoed in the reply.
  • Bytes 3-4: protocol identifier 0x0000.
  • Bytes 5-6: length 0x0006, the unit byte plus the 5 PDU bytes.
  • Byte 7: unit identifier, 0x01 in this example.
  • Byte 8: function code 0x03.
  • Bytes 9-10: start address 0x0080, which is 128 decimal.
  • Bytes 11-12: quantity 0x0001.

The decision rule comes from the capture, not from the entry field: the wire must show 00 80 in the address field. If typing the map number puts 10 20, which is 4128, on the wire, your interface adds the shift itself; remove it, because the robot wants the map number unchanged. If your interface expects data-model style entry and strips it before transmitting, enter 4128 so the wire still carries 00 80.

The fix for each capture result #

  • Malformed frame: rebuild it. Use the installation's Modbus instruction if there is one and delete the hand-rolled socket logic; otherwise make the logic write the bytes shown above and nothing else.
  • Address bytes outside the documented range: the server is refusing the address. Fix the entry convention until the capture shows the map number on the wire.
  • Valid address, exception reply, span too long: a read can begin inside the map and cross into undocumented registers. Shorten the quantity and retest.
  • Valid address and span, socket still closed with no reply: the endpoint or the path is at fault. Recheck the destination port against the robot's documented endpoint, then the capture point itself, because a healthy server answers a valid read and does not drop it silently.
  • PLC closes on a timer with no reply: compare the configured timeout with the measured request-to-reply interval in the trace and correct whichever is wrong. TCP acknowledgements prove delivery to the robot's network stack, not that Modbus ran.

Prove the read with a known value #

Put a known value into the register from the robot side first, so the PLC read becomes a pass or fail instead of a guess. The robot's script functions address the same map: write_port_register(128, 12345) sets the register and read_port_register(128) reads it back locally.

Then read one register from the PLC. The reply is 11 bytes, with length field 0x0005, function 0x03, byte count 0x02, then the data, and it must echo the transaction identifier:

00 01 00 00 00 05 01 03 02 30 39

Bytes 10-11 carry 0x3039, which is 12345 decimal, the value you wrote. That one frame proves the whole chain: framing, address convention and the server. Now extend the quantity toward what the application needs, one step at a time, and re-capture after each step. Keep test writes inside the general purpose range, because the rest of the robot's map is tied to real I/O and robot commands.

Questions asked

Should I add 4000 to every register address for this robot?

No. The robot applies the address as sent, so the shift is a client convention, not a server offset. Add it only when your interface strips it back off before transmitting, and keep it in one place: a shift applied in the PLC logic and again in the communication instruction puts a third number on the wire, 8128 when both add. One capture settles which convention your setup uses.

What does a Modbus exception reply tell me that a closed socket does not?

An exception reply means the server parsed your frame, so the MBAP header and function code are correct and the fault is in the data. Code 02, illegal data address, points at the start address or the span; code 03, illegal data value, points at the quantity field. A socket closed with no reply never got that far, which is why the frame comes before the address.

How many registers can one read request span?

Function 03 accepts a quantity of 1 to 125 registers per request; a larger value draws exception 03. A maximum-size read from the robot's first general purpose register still ends inside the documented map, but a span that crosses into undocumented addresses fails even when the start address is valid.

Keep reading

  • Troubleshooting

    Why WinCC Modbus TCP reads fail on an FX5U server

    A Modicon-driver WinCC connection to an FX5U Modbus TCP server fails when it uses port 299 and remote slave ID 255 while the FX5U listens on port 502 and answers unit ID 1, and when D0 is not addressed as holding register 4x400001. Correct those three settings, then verify ping, TCP port, a capture and a known value in D0.

    Industrial networks

  • Explainer

    Can a Modbus write change PLC outputs?

    Yes, but not by outrunning the scan. On a Modicon CPU the communication interface reaches data memory only between scans, so a write is applied whole and the next scan either consumes it or overwrites it. The real exposure is that Modbus TCP authenticates nothing: any host that can reach the CPU can write an unprotected holding register your logic unpacks into outputs, so pack status into read-only words, keep commands in a separate writable range, and enforce write protection with an IP access control list.

    Industrial networks

  • Comparison

    Choosing how a Siemens PLC talks to a Modicon M580

    An S7-1200 or S7-1500 and a Modicon M580 need no gateway: both speak Modbus TCP on their existing Ethernet ports, with the M580 as server and MB_CLIENT on the Siemens side or MB_SERVER polled by the M580's I/O scanner, and OPC UA is native to both. Add a PROFINET-to-Modbus TCP gateway only when a participant such as a PROFINET-only drive control unit cannot take a Modbus role, because the M580 has no PROFINET stack.

    Industrial networks