IMD SolutionComputing LibraryShop main store

Troubleshooting

Why a gateway shows a TCP connection but sends no payload

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

Short answer

The connection your TCP node shows is transport only. The gateway wraps its reporting upload in TLS, rejects a self-signed server certificate during the handshake, and closes the socket before a single datapoint is sent, so the log records the upload and then data lost. Give the gateway a certificate chain it trusts for the configured server name, or run a custom gateway application that talks to Node-RED directly.

On this page
  1. What the URL and port settings actually change
  2. Where your session stops
  3. The certificate verdict in the stunnel log
  4. Timing the abort in a 21:38 upload log of an X2E gateway
  5. Making the handshake pass on a local Node-RED host
  6. The paths that run fully local
  7. The decision, case by case
  8. Questions asked

You are not imagining the connection in Node-RED, but it proves one thing only: an IP route exists and the TCP handshake completed. Everything that matters happens after that. The gateway's reporting client pushes its upload through stunnel, opens a TLS session, evaluates the certificate your server presents, rejects it as self-signed, and closes the socket before a single datapoint crosses — which is why the log ends in Unexpected Device Cloud error, data lost while your TCP node still counts a client. The fix is not in a payload parser. Either present a certificate chain the gateway trusts for the configured server name, or leave the Device Cloud upload path behind and run a custom gateway application that talks to Node-RED directly.

What the URL and port settings actually change #

On the gateway's Device Cloud configuration page, the URL setting names the system that provides network access. Choosing the other entry and entering your server address and port re-points the reporting client to your host — that is all it does. The client, xbgw.reporting.device_cloud, still builds datapoints from received XBee frames and posts them to DataPoint/upload.csv, as a web request carried inside a TLS session that stunnel establishes on the gateway.

Your Node-RED host therefore receives an HTTPS client, not a stream. A plain TCP input node accepts the socket because TCP completes before TLS begins, then holds handshake bytes it cannot decode. An HTTP input node fares no better: the first bytes arriving are a TLS handshake, not a request line. Terminating TLS in front of the flow is only the transport step; the flow must still expose the path the client requests and return a response it treats as an acknowledgement.

The same layering traps other plant links, and the walkthrough of an MQTT connect that fails even though TCP works applies this stage-by-stage method to a second protocol.

Where your session stops #

What you observe at the Node-RED side Stage that failed Next check
No client ever appears TCP: address, route, port Gateway destination address and port against the listener's bind address and port
Client connects, sends nothing, disconnects TLS handshake The stunnel lines in the gateway log and the certificate chain the server presents
TLS completes but nothing decodes Request framing The path, method, headers and body the client actually sends
A message arrives yet the gateway reports data lost Response handling The status and body you return against what the client accepts as success

Yours is the second row. Work the case in this order:

  1. Confirm the Ethernet link, address, subnet and route from the gateway to the Node-RED host, and that the port configured in the Device Cloud settings is the port your listener binds.
  2. Read the gateway log at the upload timestamp and find the stunnel lines; the verdict is written there.
  3. If the log names a certificate failure, repair the trust chain and the server name before touching anything else.
  4. If TLS completes and nothing decodes, capture the request at the server and compare it with the upload contract the client follows.
  5. If the request arrives but data lost persists, compare your response with what the client acknowledges as a completed upload.

The certificate verdict in the stunnel log #

stunnel: CERT: Pre-verification error: self signed certificate
stunnel: Rejected by CERT at depth=0: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd, CN=test.myvnc.com
stunnel: SSL_connect: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
stunnel: Connection reset: 0 byte(s) sent to TLS, 0 byte(s) sent to socket

The decisive line is certificate verify failed. At depth=0 the failing object is the server certificate itself: it is self-signed, so its issuer is not in the gateway's trust store, and verification stops before the name is even compared. That is why importing your certificate onto the Node-RED side changed nothing — the gateway does not distrust the name, it distrusts the issuer. The zero-byte counters explain the empty dashboard: the session aborted during the handshake, so no application byte ever left the gateway.

Acceptance needs three independent checks: the issuing certificate authority must sit in the gateway's trust store, the certificate must be inside its validity window measured on the gateway's clock, and the server name configured in the gateway must match an identity the certificate carries. Miss any one and the handshake dies with the same symptom, so read the gateway clock as well.

A firmware switch that disables verification, where one exists, removes server authentication and leaves the link open to endpoint impersonation. Confine it to an isolated test network and restore verification before real data flows.

The trailing lines — Connection attempt failed -509, E_DP_STAT_CONN_FAIL_TCP (7), E_DP_STAT_VERSION_ERROR (30) — are consequences of the aborted session, not separate faults.

The same three checks decide any OT server that presents its own certificate; the walkthrough of an Ignition self-signed module certificate that is not trusted reads the same failure from the server side.

Timing the abort in a 21:38 upload log of an X2E gateway #

The inputs, all from this gateway's own log, times in gateway local time:

  • 21:38:20,434 — the client announces the upload to DataPoint/upload.csv
  • 21:38:20,521 — the client reports Upload contains 1 datapoints, with sender address xbee.serialIn/[00:13:A2:00:42:01:07:B7] and payload already framed
  • 21:38:23,536 — the warning Unexpected Device Cloud error, data lost
  • At the Node-RED side: one accepted client, zero bytes received

The rule: subtract the last datapoint line from the warning. The datapoint build runs inside the gateway, so a milliseconds-scale gap points at a failure after a completed connection, in request framing or response handling; a seconds-scale gap means the time went into a connection attempt that died.

The arithmetic:

  • Datapoint build: 21:38:20,521 - 21:38:20,434 = 87 ms
  • Failed upload attempt: 21:38:23,536 - 21:38:20,521 = 3.015 s

Result: the gateway framed its datapoint in 87 ms, then spent 3.015 s on a connection that returned nothing, and the socket your TCP node accepted never carried a byte.

Decision: a seconds-scale gap together with zero bytes sent places this fault at the TLS stage, so the work is the certificate chain and the server name — not the payload parser. If your own log shows the warning within the same second as the datapoint lines, the handshake passed and the fault moves to the request or response; capture the exchange at the server instead.

Making the handshake pass on a local Node-RED host #

Run the TLS side properly instead of fighting it. Terminate TLS on your Node-RED listener with a certificate issued by a certificate authority you control, put that authority's certificate in the gateway's trust store, make sure the certificate carries the server name configured in the gateway, and keep the gateway clock correct. This is the same configuration work as configuring MQTT TLS certificates in Node-RED on an edge PC, with the gateway as the verifying client.

Passing TLS is still not the finish line. After a clean handshake the client sends its upload to DataPoint/upload.csv in its own format and judges your response by its own acknowledgement rules. Reproducing that contract on a private server is possible, but it is reverse work with no specification to build from — cost it before you commit. Most fully local installations are better off leaving this upload path behind entirely.

The paths that run fully local #

  • Managed cloud path: connect the gateway to Digi Remote Manager and mirror the data into the local dashboard. Supported with no custom code, but it depends on two servers and an internet path, so it fails a strictly local requirement.
  • Redirected destination with a trusted chain: your host implements the upload contract behind a certificate the gateway trusts. Fully local in principle; reproducing the contract is the cost.
  • Industrial Automation with Modbus: when the remote devices already expose their values as Modbus registers, the gateway bridges them to your server, and running MQTT to Modbus TCP with Node-RED on an edge gateway shows the Node-RED side of such a bridge. No certificate work at all.
  • RealPort: when the application wants a serial-style connection through the gateway rather than report messages.
  • Custom gateway application: your own Python program on the X2E reads the XBee frames — MicroPython on the XBee3 modules can do the radio-side work — and defines its own framing, buffering, reconnection and acknowledgements toward a Node-RED TCP or HTTP endpoint. Fully local, both directions, and the protocol is yours to keep simple.

Whatever the path, the dashboard host sits in the plant, not under a desk; a fanless industrial mini PC mounted in the cabinet is the natural home for a Node-RED server that has to run whenever the line runs.

The decision, case by case #

  • If an external service is acceptable, connect the gateway to Digi Remote Manager and mirror locally: the supported route with the least code, but not fully local.
  • If the network must be fully local and the devices expose Modbus registers, use the Industrial Automation bridge and skip certificates entirely.
  • If a serial-style abstraction fits the application, use RealPort.
  • If you need arbitrary XBee3 payloads in both directions without any cloud, write the custom Python application on the X2E and own the framing and acknowledgements yourself.
  • If you are determined to re-point the Device Cloud upload at your own server, earn the handshake first — trusted chain, matching name, correct clock — and only then reproduce the upload contract. Until the chain is trusted, your TCP node will keep counting connections that never carry a byte.

Questions asked

Why do Connection attempt failed -509 and E_DP_STAT_VERSION_ERROR (30) follow the certificate error?

They are consequences, not separate faults. When the handshake aborts, the reporting client closes the socket, logs the TCP read failure and flags the datapoint with its connection and version status codes. Fix the certificate trust first; once the upload completes, those codes stop appearing, and no change to the payload parser can remove them earlier.

Does xbgw_main.py run on the X2E gateway?

No. That script belongs to the XBee Industrial Gateway product line and its Python environment. The X2E runs its own Python build for custom applications, so the equivalent step there is your own program, started on the gateway, that reads XBee frames and forwards them to your local server. Copying the file across without adapting it to the X2E environment will not give you the local link you want.

Is a Modbus path simpler than a custom Python application?

When the remote devices already expose their values as Modbus registers, yes. The gateway's Industrial Automation function bridges them to a server on your network and a standard Modbus node in Node-RED reads the registers directly. Keep the custom Python application for arbitrary XBee3 payloads that neither standard path represents.

Can certificate verification be switched off to prove the link works?

Only as a bench test on an isolated network. With verification off, the gateway accepts any endpoint that reaches the port, so the test proves routing, not server identity, and the link must not carry production data in that state. Prove the handshake with the trusted chain in place, then restore verification before the gateway reports anything real.

Keep reading

  • How-to

    MQTT to Modbus TCP with Node-RED on an edge gateway

    Yes: Node-RED with the node-red-contrib-modbus package can serve MQTT data to a SCADA client as Modbus TCP. Read the RTU device in Node-RED first, give the Modbus server node a port nothing else owns, and scale each MQTT payload to one integer per holding register before the first end-to-end test.

    Edge computing and IIoT

  • Troubleshooting

    Sparkplug B sends data but receives no SCADA commands

    Sparkplug B telemetry that reaches SCADA while SCADA writes never arrive is usually a direction-of-function fault: the open-source IEC SparkplugB library V1.0.0.0 implements only sending controller data to SCADA. Verify the broker path, session and authorization, watch the 30-minute demo window of the MQTT Client SL dependency, and choose a documented receive-capable implementation when writes are required.

    Edge computing and IIoT

  • Troubleshooting

    Trace an edge gateway MQTT connection failure to Azure Event Grid

    A desktop MQTT client that connects and publishes with thumbprint authentication clears only that endpoint, certificate and permission combination on that host. When the gateway fails against the same Event Grid namespace, test four stages in order on the gateway itself: network path and DNS to TCP 8883, the TLS handshake with both certificate directions and the clock, the CONNECT identity, and publish authorization on the exact topic. The first stage that fails names the fix.

    Edge computing and IIoT

Why PI AF SDK connection failures are slow to surface