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

Don't send empty username and password #1197

Merged
merged 1 commit into from
Nov 11, 2020
Merged

Don't send empty username and password #1197

merged 1 commit into from
Nov 11, 2020

Conversation

jackwilsdon
Copy link
Contributor

Since 70a247c changed how we generate options, we now end up sending an empty username and password when they are not set, instead of sending no username and password. This ends up confusing some MQTT servers, which don't properly detect an empty username/password as an anonymous login.

This can be seen most clearly in the connect flags:

b5b3814 (one commit before 70a247c)

Connect Flags: 0x02, QoS Level: At most once delivery (Fire and Forget), Clean Session Flag
    0... .... = User Name Flag: Not set
    .0.. .... = Password Flag: Not set
    ..0. .... = Will Retain: Not set
    ...0 0... = QoS Level: At most once delivery (Fire and Forget) (0)
    .... .0.. = Will Flag: Not set
    .... ..1. = Clean Session Flag: Set
    .... ...0 = (Reserved): Not set

70a247c

Connect Flags: 0xc2, User Name Flag, Password Flag, QoS Level: At most once delivery (Fire and Forget), Clean Session Flag
    1... .... = User Name Flag: Set
    .1.. .... = Password Flag: Set
    ..0. .... = Will Retain: Not set
    ...0 0... = QoS Level: At most once delivery (Fire and Forget) (0)
    .... .0.. = Will Flag: Not set
    .... ..1. = Clean Session Flag: Set
    .... ...0 = (Reserved): Not set

Setting the options to null when they're false-y seems to fix this.

@ccvca
Copy link

ccvca commented Nov 10, 2020

Just some more background information, as I just tracked down the same Problem (#1207)

It may be also possible to fix this in mqtt-packet here:

https://github.com/mqttjs/mqtt-packet/blob/2dcc70c88f0b8b146b63f017f816568fdc453ebf/writeToStream.js#L259-L265

  // Username and password
  if (username != null) {
    writeStringOrBuffer(stream, username)
  }
  if (password != null) {
    writeStringOrBuffer(stream, password)
  }

@YoDaMa YoDaMa merged commit 6a0e50a into mqttjs:master Nov 11, 2020
@jackwilsdon jackwilsdon deleted the no-empty-auth branch November 11, 2020 20:13
@zambujal
Copy link

My mqtt addon mosquito frezes and then nothing maybe because of this? not even showing errors... tried several updates... so this is just bugs...

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.

4 participants