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

Upgrade to latest MQTT.js #306

Merged
merged 13 commits into from
Sep 16, 2024
Merged

Upgrade to latest MQTT.js #306

merged 13 commits into from
Sep 16, 2024

Conversation

hardillb
Copy link
Contributor

part of #263

Description

Update mqtt.js and engines section of package.json.

Also had to change the client.connect()` call slightly to get it to work properly.

Related Issue(s)

#263

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production

Labels

  • Includes a DB migration? -> add the area:migration label

@hardillb hardillb self-assigned this Aug 13, 2024
@hardillb
Copy link
Contributor Author

These are the changes I needed to make to get #267 to work properly

lib/mqtt.js Outdated Show resolved Hide resolved
@Steve-Mcl
Copy link
Contributor

Steve-Mcl commented Aug 16, 2024

Looks good ben but the whole workaround code can go in the bin now.

I would add a suggestion to save you messing on but its out of the touched code and GH wont let me.


In short, this lot...

        // PROBLEM: ipv6 ws addresses cannot connect
        // INFO: Calling mqtt.connect('http://[::1]:8883') fails with error  ERR_INVALID_URL
        // INFO: Calling mqtt.connect(new URL('http://[::1]:8883')) fails because `connect` only accepts a `string` or `url.parse` object
        // INFO: Calling mqtt.connect(url.parse('http://[::1]:8883') fails because unlike new URL, url.parse drops the square brackets off hostname
        //       (mqtt.js disassembles and reassembles the url using hostname + port so `ws://[::1]:8883` becomes `ws://::1:8883`)
        // INFO: WS src code uses `new URL` so when `mqtt.js` passes the reassembled IP `http://::1:8883`, it fails with error ERR_INVALID_URL
        // SEE: https://github.com/mqttjs/MQTT.js/issues/1569
        // eslint-disable-next-line n/no-deprecated-api
        const brokerURL = url.parse(this.config.brokerURL)
        const _url = new URL(this.config.brokerURL)
        brokerURL.hostname = _url.hostname

simply becomes ...

        const brokerURL = new URL(this.config.brokerURL)

@hardillb hardillb requested a review from Steve-Mcl August 19, 2024 08:19
Copy link
Contributor

@Steve-Mcl Steve-Mcl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved...

MQTT JS v5.10 is now released - do we want to bump to latest or leave as is here?

Will let you decide to bump or merge :)

@hardillb
Copy link
Contributor Author

Not merging until we decide the release strategy for this, as I think we need to tag a NodeJS v14 support branch

@hardillb hardillb mentioned this pull request Sep 13, 2024
10 tasks
@hardillb hardillb marked this pull request as ready for review September 16, 2024 10:15
@hardillb
Copy link
Contributor Author

Just a moment, rebasing to pick up the package-lock.json

@hardillb hardillb merged commit eba7e17 into main Sep 16, 2024
4 checks passed
@hardillb hardillb deleted the latest-mqtt branch September 16, 2024 10:19
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.

3 participants