mqttjs / mqtt-elements

Polymer elements for MQTT
http://mqttjs.github.io/mqtt-elements/
MIT License
27 stars 6 forks source link

Username and password #11

Closed kingflurkel closed 9 years ago

kingflurkel commented 9 years ago

My broker want guest / guest username and password. I can't seem to get this working with the "options" attribute. Is this implemented already?

sandro-k commented 9 years ago

Yes it is implemented and tested!

Supply the username and password in <mqtt-connection>.options and then connect the connection with <mqtt-connection>.connect(). Currently there is no flag to indicate that credentials are needed and having the auto flag set will perform a connect right away. I will open up an issue to address this.

_computeOption: function (username, password) {
      var options = {
        protocolId: "MQTT",
        protocolVersion: 4,
        keepalive: 10,
        reconnectPeriod: 1000,
        clientId: "",
        encoding: "string",
        username: username,
        password: password
      };
      return options
    },
kingflurkel commented 9 years ago

Aha! Now I see. I was trying to use the options attr. but it first connects so no options are sent. Thanks for your reply.

kingflurkel commented 9 years ago

Also, I can't seem to use http://, it overwrites it with ws://.

sandro-k commented 9 years ago

Do you mean <mqtt-connection url="http://foo.bar"> ?

kingflurkel commented 9 years ago

Yes

sandro-k commented 9 years ago

Your issue should be fixed with 4bb8ae330e3e1c41f0b7f0e1f7511e2aff9ca4f0 and 2c90804827aada9daafd4e3310e0fb13fecc937b. Can you pleas try it again?

kingflurkel commented 9 years ago

Will do, thanks!