IMD SolutionComputing LibraryShop main store

Troubleshooting

Why the Flexy AWS IoT script fails at MQTT CONNECT with error 28

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

Short answer

Error 28 at MQTT CONNECT does not mean the WAN is down: the script prints its WAN message for any LSTERR value 28. An SSL/TLS configuration event in the event log puts the fault at the TLS hop, so check the CA, certificate and key files, then port 8883 and the Flexy clock, before touching the AWS device policy.

On this page
  1. Where the CONNECT attempt has to get through
  2. What the WAN message actually proves
  3. Check the three TLS files first
  4. Prove the network path from the Flexy itself
  5. The settings that matter only after TLS passes
  6. What happens to the data meanwhile
  7. Decision by case
  8. Questions asked

When the AWS IoT live-data script prints Operation failed (28) 73 : MQTT "CONNECT" and then WAN interface not yet ready. MQTT Launched anyway..., the WAN line is not a diagnosis. The script logs it for any 28 that GETSYS PRG,"LSTERR" returns after the CONNECT call, and the same leading value has been reported with a different suffix against a broker on the local LAN. The specific lead is the event-log entry mqtt-Problem configuring SSL/TLS: it places the fault at the TLS hop, before an MQTT session can exist. Check the three certificate files first, then the broker port and the Flexy clock, and leave the AWS device policy for last, because no topic permission can break a TLS handshake.

Where the CONNECT attempt has to get through #

The request clears five hops in order, and each hop leaves different evidence:

  • The WAN interface and route are up when the init section runs.
  • The endpoint hostname in CONF_AWSMQTTBROKERURL$ resolves.
  • Outbound TCP to port 8883 passes, which the script's own requirements call out.
  • TLS succeeds: the Flexy validates the broker chain against its CA file and presents its device certificate and key.
  • MQTT CONNECT is accepted for the configured client ID, after which publish rights apply.

An SSL/TLS event names the fourth hop. Start there: a device-policy problem lives at the fifth and cannot produce a TLS event.

What the WAN message actually proves #

The init section wraps the CONNECT call in SETSYS PRG,"RESUMENEXT",1, reads the last error with GETSYS PRG,"LSTERR", and logs its WAN message whenever that value is 28. Nothing in the branch queries the interface, so the text is a label the script author chose, not a measurement. Treat the two numbers as reported identifiers: the leading value tells you which call failed, and the suffix has no published decoding, so do not translate it into a specific socket or certificate fault. Let the event log place the fault instead.

Check the three TLS files first #

The script selects its files with these parameters, set before CONNECT:

MQTT "SETPARAM", "cafile","/usr/AWS_CA.crt"
MQTT "SETPARAM", "certfile","/usr/"+CONF_ThingName$+".cert.pem"
MQTT "SETPARAM", "keyfile","/usr/"+CONF_ThingName$+".private.key"
  • /usr/AWS_CA.crt is the server-trust file. Generate_Aws_CA_Certificate() writes it at every startup with the Starfield Services Root CA G2 certificate inside, the root AWS's server-authentication guidance names when server-certificate validation fails. Seeing the file appear after a reboot proves only that the script ran, not that its PEM is complete.
  • /usr/<ThingName>.cert.pem and /usr/<ThingName>.private.key are yours to upload. The path is built by concatenation, so each filename must match CONF_ThingName$ character for character, the certificate must be the one registered to the Thing, and the key must be its pair. Upload in binary mode; a truncated or re-wrapped PEM fails the TLS setup.
  • /usr/AWS_CA_old.crt is also generated, holds the Amazon Root CA 1 certificate, and is selected by none of the settings above. Its presence or absence changes nothing for this connection.

Never paste the private key into a log, screenshot or support ticket; verify the pairing on the device. The same CA-file discipline applies to the Java-client variant, covered in fixing the CA file and the event callback on a Flexy AWS IoT MQTT client.

Certificates carry validity dates, so a wrong Flexy clock fails intact files. Set the clock from a verified time source before the next attempt; the symptom family is described in why ping works but AWS IoT Core MQTT fails when the clock is wrong.

Prove the network path from the Flexy itself #

Test from the Flexy's own path, not from an office PC: confirm the endpoint hostname resolves on the gateway, then that an outbound TCP connection to the broker port completes. A ping reply proves only that the far end answers ICMP, as explained in why a WAN ping proves reachability, not LAN connectivity, so pair it with the port test. If the connection works by IP but not by hostname, the fault is name resolution; see why a Flexy publishes MQTT by IP but not hostname.

The settings that matter only after TLS passes #

  • CONF_AWSMQTTBROKERURL$ and CONF_ClientID$ must be copied exactly from the start.sh file in the AWS connect kit. A masked placeholder left in the script fails resolution or identity.
  • CONF_ThingName$ drives both credential filenames, so a typo here surfaces as a TLS file failure, not an identity error.
  • CONF_DeviceTopic$ must be allowed by the device policy, but the broker checks that only inside an established session.
  • The keepalive of 20 seconds governs an established session and has no effect on a failed CONNECT.

If the session establishes and then dies after the first publish, that is a different fault: why a Flexy MQTT client drops after one publish.

What happens to the data meanwhile #

While MQTT "STATUS" is not 5, the publish function appends each payload as one line to /usr/mqttmsg_db.txt and stops saving only when the file reaches the configured cap of 5,000,000 bytes. Worked example with an assumed line length: one 150-byte line per minute gives 5,000,000 / 150 = 33,333 lines, and 33,333 / 60 = 555 hours, about 23 days of buffering. A dead connection can therefore sit unnoticed for weeks while the file fills; only then are new messages dropped. Check the connection status now rather than waiting for a data-gap alarm, and expect the saved lines to be published when the session returns.

Decision by case #

  • The event log shows the SSL/TLS entry: fix the files, meaning the CA path and PEM integrity and the Thing-named certificate and key pairing, then the clock. Do not touch the device policy.
  • No SSL/TLS entry, and the WAN really was down when the init section ran: the script attempts CONNECT once, at startup, so restart the script, or reboot, after the interface is up.
  • No SSL/TLS entry, WAN up: resolve the endpoint and open outbound port 8883 from the Flexy's own path; fix DNS or the firewall rule.
  • TLS passes and the broker still refuses the session: compare the endpoint and client ID with start.sh, confirm the certificate is registered to the Thing, then check the policy topic.

Questions asked

Does error 28 always mean the WAN interface is down?

No. The script prints that message for any 28 returned after the CONNECT call, and the same leading value has been reported with a different suffix against a Mosquitto broker on the local LAN, where no WAN was involved. The number identifies which call failed, not why. Use the event log entry and the hop-by-hop checks to assign the cause.

Can I delete AWS_CA_old.crt from the usr directory?

It makes no difference to this connection. The script writes both CA files every time it starts, and none of the settings shown select the old file, so deleting it changes nothing and it reappears at the next boot. What matters is that the file named in the cafile setting exists at its exact path, is complete PEM, and holds the root the broker chain needs.

Are tag values lost while the connection is down?

Not until the buffer fills. Each payload is appended as a line to the message file on the usr directory, and the stored lines are published again once the session returns. When the file reaches its size cap the script logs that the buffer is full and drops new messages, so a long outage does cost data eventually.

Should I change the keepalive or the client ID to clear the error?

Neither setting reaches the fault. The 20-second keepalive only governs a session that already exists, and the broker evaluates the client ID only after TLS succeeds, so both are irrelevant while the handshake fails. Change them only after the SSL/TLS hop passes and the broker still refuses the connection.

Keep reading

  • Troubleshooting

    Flexy AWS IoT MQTT: fix the CA file and the event callback

    A Flexy running Java ETK 1.4.4 fails its MQTT connection to AWS IoT for two separate reasons. The cafile option names /usr/root-CA.crt while the stored file is CA.crt, so rename the file to match. The old callMqttEvent callback calls readMessage() on event 1, a status event, which makes the gateway unreachable after the JVM starts; handle the status event first and read only on the other events.

    Edge computing and IIoT

  • Troubleshooting

    Fixing an edge gateway MQTT TLS private key load failure

    The errors error:0906D06C PEM routines:PEM_read_bio:no start line and error:140B0009 SSL routines:SSL_CTX_use_PrivateKey_file mean the gateway cannot parse its own private-key file, so the failure is local and happens before the broker sees anything. On a Flexy 205 running firmware 15.0s1 the confirmed correction is the 15.0s2 firmware upgrade with the same certificate files, not new keys or AWS IoT policy edits.

    Edge computing and IIoT

  • Troubleshooting

    MQTT connect fails when TCP works: diagnose the handshake

    A successful raw TCP open to the broker port proves only routing and an open port; MQTT error 28 at Connect means the gateway ended the call with no usable session. Read the broker log during the attempt: no logged attempt means the gateway sent no MQTT data, a logged refusal means authentication or broker configuration, and an accept followed by an immediate close means a duplicate client identifier.

    Edge computing and IIoT

Why MQTT Transmission fails when MQTT Engine connects to AWS IoT Core