📶 Connectivity issue? Post like this
-
Connectivity bugs are config bugs until proven otherwise. Include this every time or expect it as the first reply: broker host + port, security mode (plain / TLS / mutual TLS), client ID, the exact topics you publish and subscribe to (credentials redacted), the client library + version, and the full connection return code or error string.
Read the return code before posting
Client libraries report why a connection failed — quote it exactly:
Code / symptom Usual meaning First check Connection refused / failed Wrong host, port, or the broker is down Ping the host; confirm the port (1883 plain, 8883 TLS) is reachable Unauthorized / bad credentials Username, password, or token rejected Regenerate the token; check for expiry and typos Topic rejected ACL blocks that topic for this client Topic must match your device ID exactly, character for character TLS verify failed CA chain not trusted by the device Correct CA cert flashed; device clock synced (unsynced clock = invalid certs) TLS handshake timeout Too little free heap for crypto Need comfortable headroom — print free heap before connecting Connects, then drops in seconds Keepalive shorter than your loop, or same client ID connected twice One client ID per device, always; keepalive longer than your longest blocking task The TLS checklist (fixes most "worked on desktop" cases)
- Sync time first — certificates are time-bound.
- Flash the right CA certificate, and actually verify against it (no insecure-mode leftovers from testing).
- Mutual auth needs the client cert + key provisioned per device, not copied across the fleet.
- If WiFi connects but MQTT fails, suspect a blocked port or firewall before suspecting code.
Stay connected, not just connected once
Reconnect with backoff (don't hammer the broker every 500 ms forever), resubscribe after every reconnect, use LWT so the fleet knows you're gone, and buffer outbound readings locally during outages instead of dropping them. A device that connects once in the lab and never recovers in the field isn't done.
Post the return code, your topics, and what the broker logs say. Tag with mqtt, wifi or tls.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login