-
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 refused: Bad username or password #1345
Comments
Are the credentials just wrong?
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Nicolas ***@***.***>
Sent: Friday, October 22, 2021 4:35:45 PM
To: mqttjs/MQTT.js ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [mqttjs/MQTT.js] Connection refused: Bad username or password (Issue #1345)
Hi! I'm trying to connect to a Thingstream broker running MQTT 3.1.1, using user and pass.
var username = "user";
var pass = "pass";
var client = mqtt.connect('mqtt:mqtt.thingstream.io',
{
username: username,
password: pass,
}
)
But I'm getting this error:
Error: Connection refused: Bad username or password
at MqttClient._handleConnack (\mqttNode\node_modules\mqtt\lib\client.js:1190:15)
at MqttClient._handlePacket (\mqttNode\node_modules\mqtt\lib\client.js:424:12)
at work (\mqttNode\node_modules\mqtt\lib\client.js:321:12)
at Writable.writable._write (\mqttNode\node_modules\mqtt\lib\client.js:335:5)
at doWrite (\mqttNode\node_modules\readable-stream\lib\_stream_writable.js:409:139)
at writeOrBuffer (\mqttNode\node_modules\readable-stream\lib\_stream_writable.js:398:5)
at Writable.write (\mqttNode\node_modules\readable-stream\lib\_stream_writable.js:307:11)
at Socket.ondata (internal/streams/readable.js:731:22)
at Socket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12) {
code: 4
Any suggestion? Thanks in advance!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmqttjs%2FMQTT.js%2Fissues%2F1345&data=04%7C01%7Cyoseph.maguire%40microsoft.com%7C5e006c7fd55542b8f5a208d995a3e8ff%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637705353483246087%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=y%2F8oaEUEoO3V4UEwBCfaipjPiA5UQWW1C4r4c4gcR3o%3D&reserved=0>, or unsubscribe<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB6VMLG52RQJSLVQU3YD2KDUIHKLDANCNFSM5GRNTBSA&data=04%7C01%7Cyoseph.maguire%40microsoft.com%7C5e006c7fd55542b8f5a208d995a3e8ff%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637705353483256079%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=4aZPbrMkhiYaFiTvpW7fE%2FhdgKhEfrT4dNBRXSDm71w%3D&reserved=0>.
|
Nop, I'm able to connect without problems using mosquitto client. |
Is that the correct way to specify a user and password? Thanks! |
Probably because mosquitto_pub and mosquitto_sub bypass authentication on mosquitto. As i remember, there should be a root user called |
Is there a solution for this issue? I'm getting the same error connecting to RabbitMQ. const client = mqtt.connect(mqtt://hostname:1883, {
username: "username",
password: "password",
}); |
when i put username and password mqtt does not work anymore
using command line client works fine with username and password |
MQTT 5.0.0 BETA is now available! Try it out and give us feedback: |
I used the version 5.3.5 also have same issue. |
Can you connect using another client with same username/password? |
do you have a way to see what's coming to the broker? I would be curious to know what broker receives, I think it could be code/decode issue with the password/username, does they contain some strange char/symbol? |
Hi RobertsLando, Thanks for you reply. Actually the username/password have ‘-’ symbol between the string word. How can I fixed this decode issue? |
Mine was just a supposition, the |
Thanks for your suggestions. This is my fault. Because our MQTT broker setting the HTTP auth. The backend of the cloud server is responsible for verifying the username/password send by Websocket. Always return bad username/password when there is no response from the backend. |
Closing this for now as I have a feel that when this happens it's most likely a user issue |
Hi! I'm trying to connect to a Thingstream broker running MQTT 3.1.1, using user and pass.
But I'm getting this error:
I'm able to connect without problems using mosquitto client.
Any suggestion? Thanks in advance!
The text was updated successfully, but these errors were encountered: