Repository navigation
Fix MQTT connect action dropping its url when repeated - #6019
Merged
knolleary merged 1 commit intoOct 21, 2026
Merged
Conversation
A connect action's msg.broker.url was only applied when it differed from the current brokerurl. Sending the same action again therefore rebuilt the url from the configured broker and port, and the node stayed in "connecting" when that broker was not reachable. A url in the action is now always used. An action that only sets broker/port still overrides an earlier url, as before. Fixes node-red#5095
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.
Proposed changes
Fixes #5095
The broker node only applied
msg.broker.urlfrom a connect action when it differed from the currentbrokerurl. The first action worked, but repeating it (withforce, or after a disconnect) rebuilt the url from the configuredbroker/port. With the config from the issue, the node then sat in "connecting" onmqtt://-:1883.Now a
urlin the action is always used, as the help text describes. An action that only setsbroker/portstill replaces an earlier url, same as before.The new test in
21-mqtt_spec.jsneeds no broker. It applies the sameurltwice, then abroker/portoverride, and checksbrokerurlafter each step.npx mocha --exit test/nodes/core/network/21-mqtt_spec.json Node 22.23.2 (the 28 pending tests need a real broker):expected MQTTBrokerNode {...} to have property brokerurl of 'mqtts://broker.example.com' (got 'mqtt://localhost:1883')npm run lintpasses, though it only covers the editor-client sources.I also replayed the issue's steps against a minimal local broker stub. Before the fix, a second "connect with force", or a disconnect followed by the same connect, left the node connecting to
mqtt://-:1883. With the fix, both reconnect to the action's url.Checklist
npm run testto verify the unit tests passI ran the MQTT spec rather than the full
npm run test, which builds the editor first.AI disclosure: AI coding tools (Claude Code) helped write this change and the test. I reviewed the change and ran the tests above before submitting.