Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: url path is removed at wechat environment #1892

Closed
timzaak opened this issue Jun 20, 2024 · 2 comments · Fixed by #1894 · 4 remaining pull requests
Closed

[Bug]: url path is removed at wechat environment #1892

timzaak opened this issue Jun 20, 2024 · 2 comments · Fixed by #1894 · 4 remaining pull requests
Labels
bug wechat WeChat related issues

Comments

@timzaak
Copy link
Contributor

timzaak commented Jun 20, 2024

MQTTjs Version

5.7.0

Broker

NO

Environment

Browser

Description

// use string
ws.connect('wxs://www.example.com/mqtt', {timerVariant: 'native',})
// use object
ws.connect({
    host: 'www.example.com',
    path: '/mqtt',
    protocol: 'wxs',
    timerVariant: 'native',
})

the url would change to wss://www.example.com/

【expect】
the url would be wss://www.example.com/mqtt

Minimal Reproduction

as description

Debug logs

NO LOG

@timzaak timzaak added the bug label Jun 20, 2024
@timzaak timzaak changed the title [Bug]: url path is removed in wechat [Bug]: url path is removed at wechat environment Jun 20, 2024
@timzaak
Copy link
Contributor Author

timzaak commented Jun 20, 2024

delete opts.path

This delete, need add

	if (opts.unixSocket) {
		opts.protocol = opts.protocol.replace('+unix', '') as MqttProtocol
                 // the next line needs change to this
	} else if (!opts.protocol?.startsWith('ws') && !opts.protocol?.startsWith('wx') && !opts.protocol?.startsWith('ali')) {
		// consider path only with ws protocol or unix socket
		// url.parse could return path (for example when url ends with a `/`)
		// that could break the connection. See https://github.com/mqttjs/MQTT.js/pull/1874
		delete opts.path
	}

@robertsLando
Copy link
Member

!opts.protocol?.startsWith('wx')

This should be true if you are using protocol wxs so the path should not be deleted from options

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