feat(mqtt): expose write retransmission as WRITE_MAX_ATTEMPTS - #64
Merged
Conversation
#54 added write_max_attempts to DtlsCoapSession, off by default, on the argument that retransmitting into an appliance already dropping under load turns one lost write into several and that RFC 7252 §4.5 dedupe is unverified on RT-OCF. Turning it on is meant to follow a measurement. The flag was constructor-only and session_once() did not pass it, so the reference bridge was the one deployment that could take that measurement and the only one that could not reach the switch. WRITE_MAX_ATTEMPTS now sits in SharedConfig beside the other int knobs and reaches the session. It defaults to 1, which is a single send and today's behaviour, so a bridge that never sets it is unchanged. docker-compose passes .env through with env_file, so this needs no compose edit on the host. Tests cover the default, the env var, a non-numeric value stopping the process at startup the way the other int knobs do, and the call site naming the SharedConfig field so the two stay wired together.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#54 added
write_max_attemptstoDtlsCoapSessionand left it off, on the argument that retransmitting into an appliance already dropping under load turns one lost write into several, and that RFC 7252 §4.5 dedupe is unverified on RT-OCF. Turning it on is meant to follow a measurement on real hardware.The flag could only be set when a session was built, and
session_once()did not set it. The reference bridge is the one deployment that can take that measurement, and it was the only one that could not reach the switch. I said as much on #54, so this is my half.What this does
WRITE_MAX_ATTEMPTSjoinsSharedConfigbeside the other int knobs and reaches the session. It defaults to1, a single send and today's behaviour, so a bridge that never sets it is unchanged.docker-compose.ymlalready passes.envthrough withenv_file, so no compose edit is needed on the host.Process-wide, matching
HEALTH_INTERVAL_SandPING_INTERVAL_S. Per-appliance would let a measurement target just the device dropping writes, and that is an easy follow-up if it turns out to be wanted.No clamping in the bridge. A non-numeric value stops the process at startup the way
MQTT_PORTdoes, and0is floored by the library's ownmax(1, int(...)).Tests
Five, covering the default, the env var, a non-numeric value raising at startup, the kwarg reaching
DtlsCoapSession(...), and the call site naming theSharedConfigfield so the two stay wired together. Each was checked against a mutant: dropping the kwarg, flipping the default to 3, hardcoding the env read, and substituting a literal at the call site are all caught. Full suite 426.On hardware
Deployed to the reference bridge, one dryer and one oven. The container was running a tree that predated #54, so this run soaks that merge as well.
Start to seeded in 9s and 11s. Both appliances went
push_active → online, sweeps completed, and the knob was read back inside the running container:SharedConfigat 1, the call site wired, and the kwarg arriving at the realDtlsCoapSession(...)call at 1, then at 3 withWRITE_MAX_ATTEMPTS=3in the environment.Steady-state windows against the pre-deploy baseline on the same container, discarding the partial window containing the connect:
Both sit inside their baseline ranges.
mqtt_demo/is outside the distributed package, so none of this reaches the wheel.