-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Connection problem with IPv6 addresses #1130
Comments
Hi, I did some digging and the problem seems to be in Nodejs url.parse used in lib/connect/index.js url.parse('ws://[::1]:9001/',true)
Url {
protocol: 'ws:',
slashes: true,
auth: null,
host: '[::1]:9001',
port: '9001',
hostname: '::1',
hash: null,
search: null,
query: [Object: null prototype] {},
pathname: '/',
path: '/',
href: 'ws://[::1]:9001/'
} as you can see the brackets are in the host but not in the hostname anymore. Whereas the URL constructor works fine: new URL('ws://[::1]:9001/')
URL {
href: 'ws://[::1]:9001/',
origin: 'ws://[::1]:9001',
protocol: 'ws:',
username: '',
password: '',
host: '[::1]:9001',
hostname: '[::1]',
port: '9001',
pathname: '/',
search: '',
searchParams: URLSearchParams {},
hash: ''
} Node's documentation is quite clear on the subject:
An obvious fix seems to be to replace Kind regards, |
It turned out to be a bit more work as the URL class is a bit special. I got a version working (although CI fails on node 10 due to a unrelated problem) at https://github.com/seriousme/MQTT.js/tree/replace-url-parse-by-url-class I can do a PR if you like. Kind regards, |
Hello,
we are trying to use MQTT.js with IPv6 addresses but we can't connect an MQTT broker:
This code throws an exception:
It seems the library skips
[]
. I've checked this URL with another library. It works fine.AB#8505545
The text was updated successfully, but these errors were encountered: