Skip to content

fix(connect): path is lost when using servers#2040

Open
Mika56 wants to merge 1 commit intomqttjs:mainfrom
Mika56:patch-servers-path
Open

fix(connect): path is lost when using servers#2040
Mika56 wants to merge 1 commit intomqttjs:mainfrom
Mika56:patch-servers-path

Conversation

@Mika56
Copy link
Copy Markdown

@Mika56 Mika56 commented Feb 26, 2026

When using servers option, path is not copied from server. However, this path may be needed for ws (and wss)

const client = mqtt.connect({
    servers: [
        {"host":"192.168.30.1", "protocol": "mqtt", "port": 1883},
        {"host":"192.168.30.1", "protocol": "ws", "port": 8084, "path": "/mqtt"}
    ],
});

Say client is unable to connect using mqtt:// and tries to fallback using ws://, then path will always be set to /. With this patch, path is copied from server to client options.

@robertsLando
Copy link
Copy Markdown
Member

@Mika56 thanks for your PR! Could you add a unit test that covers this please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants