TCP Errors 56 and 66: Troubleshooting VxWorks sbRIO

Daniel Price5 min read
Industrial NetworkingOther ManufacturerTroubleshooting
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

A LabVIEW TCP application connecting a Windows 7 client or server to a VxWorks sbRIO can report error 56, intermittent connection failures, and delayed STM messages when connection and read timeouts are too short. The demonstrated corrections were to increase the TCP Open, Listen, and STM metadata read timeouts and address Nagle buffering. Error 66 was observed, but the available evidence does not establish its meaning or root cause.

Separate the observed failure modes

Observation Supported interpretation Engineering response
Error 56 from TCP Open Connection or TCP Read The operation timed out. On a read, this can mean that the requested data was not available before the timeout; it does not by itself prove that the connection is invalid. Increase the applicable timeout and retain the connection unless a separate failure or application-level inactivity rule requires closure.
Error 66 The evidence records the error but does not identify its definition or cause. Capture the primitive, endpoint role, timing, and connection state when it occurs before assigning a cause.
Client starts before the server listener A TCP client cannot connect until a listener is active on the destination port. A refused connection may report error 63. Start the listener first or make the client retry its open operation after a connection failure.
STM metadata read returns junk or times out A timeout that is too short can expire before the complete framed field arrives. Use a read timeout long enough to receive the requested field and preserve incomplete frame bytes.
Messages arrive in bursts and the backlog grows The reported buffering cause was Nagle's algorithm. Failure to consume data correctly after changing read behavior can also leave bytes queued. Disable Nagle where supported, then verify that every complete frame is removed from the receive path.

Why a zero-timeout STM read can corrupt framing

STM communication uses metadata that includes the information needed to determine the remaining message length. A TCP stream can split that metadata across reads. A timeout of 0 ms may therefore expire after only part of the metadata has arrived when the peers are on different machines, even though the same setting appears to work through one interface on one PC.

With STANDARD read behavior, bytes returned before a timeout are removed from the stream. If the application discards those partial bytes and retries the full metadata read, the next attempt starts partway through the field and loses frame alignment. BUFFERED behavior allows the application to retry a timed-out request without consuming the incomplete requested byte sequence, but the application must eventually perform a successful consuming read. Otherwise, queued data can continue to accumulate.

Establish the TCP session reliably

For this architecture, the server owns the Listen operation and the client owns the Open operation. Startup order must not be treated as synchronization; the client needs an explicit retry policy whenever the listener may not yet exist.

  1. Start the server listener on the intended endpoint before expecting a successful client connection.
  2. Configure nonzero, operationally sufficient timeouts on TCP Open, Listen, every TCP Read inside the STM metadata path, and any wrapper VI that supplies those values. The evidence does not establish one universally correct duration.
  3. If Open fails before the listener is ready, retain the client actor and retry instead of treating the first failure as permanent.
  4. After connection, treat error 56 on a polling read as a no-data timeout unless another error or an application-level inactivity test shows that the peer is unavailable.
  5. For framed reads, retain incomplete bytes until the entire metadata field and declared payload are available. When using an application buffer, append each received segment, extract all complete messages in a loop, and retain only the trailing incomplete message.
  6. If small writes or heartbeats remain delayed and messages arrive in bursts, disable Nagle's algorithm through the supported platform mechanism. Do not assume that changing the read timeout alone resolves write-side buffering.

Protect heartbeat handling from transport timing

The affected application expected a heartbeat in each direction every 250 ms and declared the peer dead after approximately one or two seconds. Those limits made delayed delivery visible as a false peer failure. Evaluate liveness from the timestamp of the last complete valid message, not from a single error 56. Keep the heartbeat failure threshold separate from the timeout used by an individual TCP Read.

Do not use a 0 ms framed read merely to create a fast poller. Throttle the actor loop independently while allowing the transport read enough time to complete its requested field, or implement a persistent receive buffer that safely carries partial frames between iterations.

Verify the correction

Test connection establishment and sustained traffic independently so that startup timing, framing, and buffering do not mask one another.

Test Pass condition
Server-first startup The client connects and the server receives the complete message sequence without frame errors.
Client-first startup Initial Open failures are retried, and the client connects after the listener starts.
Idle connection Error 56 does not close an otherwise valid connection; later data can still be received.
Fragmented framed message Partial metadata is preserved, and the next read reconstructs exactly one valid frame without junk bytes or lost alignment.
Sustained heartbeat and application traffic Complete messages are consumed continuously rather than arriving in expanding bursts, and receive timestamps advance within the application's liveness requirement.
Nagle enabled versus disabled If disabling Nagle removes burst delivery under the same workload, write-side packet buffering is confirmed as a contributor.

If error 66 remains after these corrections, log it separately with the failing primitive and connection state. The evidence does not support grouping it automatically with the timeout or Nagle problems.

FAQ

Does LabVIEW TCP error 56 mean the connection is closed?

No. In the documented case, error 56 is a timeout and can simply mean that no data arrived before the read expired. Keep the connection unless another failure or the application's last-valid-message timer requires closure.

Why does a 0 ms TCP Read work locally but fail with an sbRIO?

A local transfer can make the requested bytes immediately available, while a transfer between machines may deliver STM metadata in segments. A 0 ms timeout can expire on the partial field, causing error 56 or frame corruption if those bytes are consumed and discarded.

Why do sbRIO TCP messages arrive in bursts?

In this case, Nagle's algorithm caused the packet-buffering problem. Disable it through the supported platform mechanism, then confirm that the receive logic also consumes every complete frame so bytes do not remain queued.

Back to blog