honor --timeout during mqtt connect handshake#59
Merged
Conversation
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.
Summary
mqdb list --timeout 2(and every other CLI command) didn't honor--timeoutduring the MQTT CONNECT handshake.connect_clientincrates/mqdb-cli/src/common.rsonly wrapped the request/response wait intokio::time::timeout; the underlyingMqttClient::connect[_with_options]calls had no timeout. Against a TCP listener that accepts the connection but never sends CONNACK (silent broker, half-open NAT, firewall drop after SYN-ACK), every command would hang indefinitely.Reported repro:
timeout 8 mqdb list ... --timeout 2exits 124 against a silent listener but ~2.0s against a healthy broker.The fix wraps the connect future in
tokio::time::timeout(Duration::from_secs(conn.timeout), ...)and surfacesconnect to {broker} timed out after {N}son expiry. Affects every command that goes throughconnect_client(list, read, create, update, delete, schema, constraint, watch, etc.).mqdb-cli0.7.5 → 0.7.6.Test plan
cargo test -p mqdb-cli --test cli_test— 4 → 5 tests (one regression test added).test_cli_connect_timeout_against_silent_listenerspawns astd::net::TcpListenerthat accepts the connection without speaking MQTT, then assertsmqdb list ... --timeout 2exits within 5s with a "timed out" error.cargo make clippy— clean (pedantic, all targets + wasm).cargo make format-check— clean.timeout 8); post-fix, command exits in 2.018s withError: "connect to 127.0.0.1:19999 timed out after 2s".cargo test(default features) — full workspace clean (no regressions). Themqtt-bridge-gatedmqtt_transport_heartbeat_roundtripintegration test (deprecated transport perCLAUDE.md) is environmentally flaky on a hardcoded port 11883; not a regression from this PR.