eclipse / paho.mqtt.javascript

paho.mqtt.javascript
Other
1.15k stars 467 forks source link

Password is required #67

Closed Klaster1 closed 8 years ago

Klaster1 commented 8 years ago

The server I connect to uses username only for authentication, so I wan't to omit it from options passed to connect. But this line of mqttws31.js specifies that password option should be of "string" type.

Luckily, I can set password: null as a prototype property in order to bypass type validation:

        client.connect(Object.assign(Object.create({
            password: null
        }), {
            userName,
                        // ...
        }))

Maybe something should be done about it?

jpwsutton commented 8 years ago

Hi, when you set your connect options do you set password? If you do not set any password property in the connectOptions, then it should be left null.

Klaster1 commented 8 years ago

When I don't set password and set userName, the following error is thrown:

mqttws31.js:1741 Uncaught Error: AMQJS0013E Invalid argument undefined for connectOptions.password.

If I set password to null, then I get another error thrown by validate function:

AMQJS0012E Invalid type object for password.validate @ mqttws31.js:138

jpwsutton commented 8 years ago

Looks like the if statement responsible for checking if a password had been supplied without a username had been switched. I've resolved this and delivered the changes to the develop branch which should move to release at the beginning of June.