Troubleshooting
Why a Flexy MQTT client drops after one publish on firmware 14.0s01
Short answer
A broker log that shows CONNACK, one QoS 1 publish of 1,228 bytes, PUBACK for message ID 1 and then a socket error places the fault after a completed publish, not at reachability. Return the gateway to the firmware 13.0 with Java ETK 1.4.2 pair or apply the vendor's documented workaround for 14.0s01, then accept recovery only after an hour of sustained publishing.
On this page
- Why does my Flexy drop the MQTT session right after the first publish?
- What does each Mosquitto log line tell me?
- Is this a broker reachability problem?
- Which change broke it: firmware 14.0s01 or Java ETK 1.4.4?
- How do I test one change at a time?
- What is the documented fix for firmware 14.0s01?
- How do I prove the fix holds before I trust it again?
- Questions asked
A Flexy on firmware 14.0s01 that publishes exactly one MQTT message, takes its PUBACK and then vanishes from both the broker log and eCatcher is not fighting the broker: the log shows a complete session that lived about one second. Because the same maintenance step moved firmware 13.0 to 14.0s01 and the Java ETK library from 1.4.2 to 1.4.4, the suspect is the pair, and the fix is to return to the pair that worked or apply the vendor's documented workaround for this symptom. Verify recovery with an hour of sustained publishing, never with the first CONNACK — the failed session produced a clean one too.
Why does my Flexy drop the MQTT session right after the first publish? #
Because the broker accepted the connection, acknowledged a complete QoS 1 publish and then lost the socket, the fault sits in the client or its firmware pair after delivery, not in reachability, authentication, TLS or the payload itself.
The same moment took the gateway's management connection down — eCatcher showed the Flexy offline while the broker logged the socket error — and that combination widens the suspect from the MQTT library to the device as a whole. The code-level instinct blames MqttClient.connect, because that is where execution stops, but the log proves the connect completed: the broker returned CONNACK (0, 0) and one publish flowed. When a gateway stops servicing its broker and its management tool together, the runtime inside it stalled; the MQTT conversation is the victim, not the culprit.
What does each Mosquitto log line tell me? #
Read the six lines as a completed handshake plus a transport death: CONNACK return code 0, one 1,228-byte QoS 1 publish to s/someTopic under message ID 1, a matching PUBACK, then a socket error — all inside one second, with keep-alive agreed at 60 seconds.
| Broker log line | What it proves |
|---|---|
| New connection from the Flexy on port 8883 | TCP reachability and the broker's TLS listener were up; 8883 is the usual MQTT-over-TLS port. |
New client connected as Flexy (c1, k60, u'Flexy') |
Clean session requested, 60-second keep-alive agreed, the Flexy credentials accepted. |
Sending CONNACK to Flexy (0, 0) |
First field 0: connection accepted. Second field 0: no stored session to resume. |
Received PUBLISH from Flexy (d0, q1, r1, m1, s/someTopic, 1228 bytes) |
One publish left the Flexy: not a duplicate, QoS 1, retain flag set, packet ID 1. |
Sending PUBACK to Flexy (Mid: 1) |
The broker parsed and accepted the payload; the QoS 1 handshake for packet ID 1 closed cleanly. |
Socket error on client Flexy |
The TCP connection died at the broker's end; the broker dropped the client. |
A payload the broker cannot parse never earns a PUBACK: the broker logs a malformed packet and disconnects the client, which is the failure covered in Why a Mosquitto broker logs malformed packet on a PLC MQTT client. This log shows the opposite — parse, accept, acknowledge — and then the transport died, so the payload contents are not the suspect.
Is this a broker reachability problem? #
No — a reachability fault stops the log at the TCP connect or at a rejected CONNACK, and this log got past both, so re-testing pings, firewall rules or the broker itself will change nothing.
CONNACK with return code 0 certifies the TCP path, the TLS handshake on port 8883 and the credentials at that instant; the PUBACK certifies that the broker parsed and accepted the payload. That puts this case at the opposite end from Fix a PLC MQTT client that never reaches your broker, where the log never gets past the connection attempt.
The timestamps settle the timing question. The broker logged the new connection at epoch second 1576793767 and stamped connected, CONNACK, PUBLISH, PUBACK and the socket error all at 1576793768, so 1576793768 - 1576793767 = 1 second covers the entire session. The client had negotiated k60, a 60-second keep-alive, and the MQTT rule lets a broker drop an idle client only after 1.5 × 60 s = 90 seconds of total silence. The session died 89 seconds before it could qualify as idle, so nothing about it timed out: the client side stopped servicing an active connection, which matches the management connection going down at the same moment.
Which change broke it: firmware 14.0s01 or Java ETK 1.4.4? #
The upgrade moved firmware 13.0 to 14.0s01 and Java ETK 1.4.2 to 1.4.4 in one maintenance step, so the log dates the fault but cannot name the guilty component — treat the pair as one suspect and separate it by testing, not by reading code.
The pair before the upgrade ran this exact code without a fault, which is what makes the upgrade the only event correlated with the onset. The upgrade also had a motive, the new MqttClient.getStatus() call, but the failing log never reaches a status call: the session connects, publishes once and dies inside the connect path. The evidence blames the pair, not the new method, so do not delete the call out of caution and do not add any new call while you bisect. Version-bump breakage in the Java layer is a known family on this platform — Why a Flexy Java MQTT client crashes or throws NoSuchMethodError documents a sibling case where an ETK update broke previously working code.
How do I test one change at a time? #
Run the smallest program that connects and publishes — a fixed 64-byte counter string every 5 seconds is enough — and move firmware and ETK forward one step at a time, capturing the broker log for every combination.
- Save the failing broker log with its timestamps before touching anything; every later comparison reads against it.
- Roll back to the pair that ran this code before — firmware 13.0 with Java ETK 1.4.2 — and expect repeated publishes with no socket error. If the rollback still fails, stop: the remaining suspects are the broker host and the network path, not firmware.
- Move one component forward at a time, but only to pairings the vendor's release notes list as compatible, and capture the broker log plus the device state at each step. If the vendor publishes only 14.0s01 with ETK 1.4.4 as a pair, skip the mixing and take the documented workaround instead.
- Keep the test program minimal: connect and publish the counter string at a fixed interval. That removes the production payload and scheduler as variables while the firmware pair is under test.
- Freeze everything else for the whole isolation window: no new library calls, no payload edits, no retain-flag changes — a second moving variable hides the first one.
If that Flexy also carries the plant's remote-access or alarm traffic, do the rollback in a window when the line can run without it, because the device will drop offline and may reboot during the test.
What is the documented fix for firmware 14.0s01? #
The vendor's support channel documents a workaround for this exact connect-time hang on firmware 14.0s01, and deployments that applied it returned to normal publishing — so the fix is that workaround, applied exactly as documented, not a code rewrite.
Two details decide whether the fix holds. First, match the note to your exact build: the workaround is documented against firmware 14.0s01 with Java ETK 1.4.4, so confirm the note names that build before applying anything, and take it from the vendor's official support portal rather than a secondhand summary. Second, record what changed — build, ETK version, and the setting or code line the workaround touches — in the change log, so the next upgrade is tested against a written baseline instead of memory. Check the release notes for a newer build that incorporates the fix; if one exists, move straight to it and repeat the test below instead of layering a workaround onto an old build.
How do I prove the fix holds before I trust it again? #
Acceptance is sustained publishing: the session must survive the first PUBACK and keep delivering at the production interval for at least an hour with no socket error and the gateway still online in its management tool.
CONNACK and the first PUBACK both happened during the failure, so neither can certify the fix. Run the soak and check three things:
- Broker log: PUBLISH and PUBACK pairs repeating at the production interval, with no new
Socket errorline. - Device: still reachable in its management tool when the hour ends.
- Records: the change log names the firmware build, the ETK version and the workaround or rollback that produced the pass.
Then the decision for each outcome. If the rollback alone restores service, run production on the working pair and treat the upgrade as blocked until the vendor ships a fixed pairing you have re-tested. If the documented workaround holds, pin the exact build and workaround reference in the change record and gate every future upgrade on a repeat of this hour. If neither holds, leave the unit on the working pair, attach the broker log and the minimal-test results to the vendor support case, and stop changing code until the vendor answers.
Questions asked
Does this failure also apply to firmware 14.1 or newer builds?
The evidence here covers firmware 14.0s01 with Java ETK 1.4.4 only. Newer builds may already contain the fix, so read the vendor's release notes before assuming the symptom survives. The test method transfers either way: capture the broker log, upgrade as one documented pairing, then require an hour of sustained publishing before the gateway returns to service.
Should my tag publishes set the retain flag?
The failing publish carried the retain flag set, but nothing proves the flag caused the drop, so do not change it during isolation. Afterwards, decide on purpose: a periodic tag dump does not need retain, and a retained 1,228-byte payload makes the broker hand every new subscriber a stale snapshot of live values. Keep retain for genuine last-known-state topics.
How long should the soak test run after the fix?
At least one hour at the production publish interval; use a full shift when the gateway also carries remote access or alarms. This failure fired within one second of the first PUBACK, so a ten-publish smoke test can pass while a shift-long run still fails, and the soak is what turns a workaround into an accepted fix.
Can I still upgrade later to get the MqttClient.getStatus() method?
Yes. The log never shows the status call in the failing path, so the method itself is not proven guilty. Plan that upgrade as its own change: pick a firmware and Java ETK pairing the release notes list together, capture a broker log before and after, and repeat the one-hour soak before the gateway goes back into production.
What if the rollback to firmware 13.0 still shows the socket error?
Then the firmware pair was not the whole cause, and the remaining suspects are the broker host, the network path or something that changed on the device at the same time. Re-run the minimal publisher against a second broker on a laptop before reopening the firmware question, and bring both broker logs to the vendor support case.