mysensors / MySensors

MySensors library and examples
https://www.mysensors.org
1.32k stars 895 forks source link

RPI mqtt gateway not working with user/password authentication #1518

Closed piotrraczynski closed 2 years ago

piotrraczynski commented 2 years ago

I'm unable to connect to mqtt server (based on mosquitto 1.5.7) with user/password authentication. Passwordless connection works fine. At the same time I'm able to connect to the same broker with mosquitto_sub client.

I checked development branch, 2.3.1 and 2.2.0 tags.

gateway config:

./configure --my-transport=rfm69 --my-rfm69-frequency=868 --my-is-rfm69hw --my-gateway=mqtt --my-controller-ip-address=192.168.1.45 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-mqtt-client-id=mosquitto --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18 --extra-cxxflags="-DMY_RFM69_NETWORKID=(100)" --my-mqtt-username=mosquitto --my-mqtt-password=123456

debug output:

Mar 27 21:07:17 INFO Starting gateway... Mar 27 21:07:17 INFO Protocol version - 2.4.0-alpha Mar 27 21:07:17 DEBUG MCO:BGN:INIT GW,CP=RPNGL---,FQ=NA,REL=0,VER=2.4.0-alpha Mar 27 21:07:17 DEBUG TSF:LRT:OK Mar 27 21:07:17 DEBUG TSM:INIT Mar 27 21:07:17 DEBUG TSF:WUR:MS=0 Mar 27 21:07:17 DEBUG TSM:INIT:TSP OK Mar 27 21:07:17 DEBUG TSM:INIT:GW MODE Mar 27 21:07:17 DEBUG TSM:READY:ID=0,PAR=0,DIS=0 Mar 27 21:07:17 DEBUG MCO:REG:NOT NEEDED Mar 27 21:07:17 DEBUG MCO:BGN:STP Mar 27 21:07:17 DEBUG MCO:BGN:INIT OK,TSP=1 Mar 27 21:07:17 DEBUG GWT:RMQ:CONNECTING... Mar 27 21:07:17 DEBUG connected to 192.168.1.45 Mar 27 21:07:18 DEBUG !GWT:RMQ:FAIL Mar 27 21:07:18 DEBUG TSM:READY:NWD REQ Mar 27 21:07:18 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: Mar 27 21:07:18 DEBUG GWT:RMQ:CONNECTING... Mar 27 21:07:18 DEBUG connected to 192.168.1.45 Mar 27 21:07:19 DEBUG !GWT:RMQ:FAIL Mar 27 21:07:19 DEBUG GWT:RMQ:CONNECTING... Mar 27 21:07:19 DEBUG connected to 192.168.1.45 Mar 27 21:07:20 DEBUG !GWT:RMQ:FAIL Mar 27 21:07:20 DEBUG GWT:RMQ:CONNECTING... Mar 27 21:07:20 DEBUG connected to 192.168.1.45

mosquitto log: 1648415219: New connection from 192.168.1.105 on port 1883. 1648415219: Socket error on client , disconnecting. 1648415220: New connection from 192.168.1.105 on port 1883. 1648415220: Socket error on client , disconnecting. 1648415221: New connection from 192.168.1.105 on port 1883. 1648415221: Socket error on client , disconnecting. 1648415222: New connection from 192.168.1.105 on port 1883. 1648415222: Socket error on client , disconnecting.

piotrraczynski commented 2 years ago

Also tried 2.0.14 mosquitto from source. On that version, with some debugging logs I got (from the broker):

1648458618: New connection from 192.168.1.105:57522 on port 1883. 1648458618: Sending CONNACK to mosquitto (0, 5) 1648458618: Client mosquitto disconnected, not authorised. 1648458618: New connection from 192.168.1.105:57524 on port 1883. 1648458618: Sending CONNACK to mosquitto (0, 5) 1648458618: Client mosquitto disconnected, not authorised.

the password I provide is correct.

mfalkvidd commented 2 years ago

Is the password as simple as 123456, or does it contain any special characters that might become mangled by the shell or the configure script?

piotrraczynski commented 2 years ago

I was not able to get any password working. I started with more complicated one but then settled with 123456. I also printed username and password from mysgw itself as debug strings. They do not look mangled in any way.

Anyway, at least temporary I started to use mqtt with no password but actually setup my external gateways in zerotier network.

pt., 1 kwi 2022 o 21:42 Mikael Falkvidd @.***> napisał(a):

Is the password as simple as 123456, or does it contain any special characters that might become mangled by the shell or the configure script?

— Reply to this email directly, view it on GitHub https://github.com/mysensors/MySensors/issues/1518#issuecomment-1086263077, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAS57R7OK4ZKN3DO7E65LKDVC5GTNANCNFSM5RZKFP5Q . You are receiving this because you authored the thread.Message ID: @.***>

mfalkvidd commented 2 years ago

@piotrraczynski I think I found the problem. The parameter to ./configure is --my-mqtt-user, not --my-mqtt-username

mfalkvidd commented 2 years ago

The configure command actually outputs this when inputting my-mqtt-username:

[WARNING] Unknown option detected:--my-mqtt-username=mosquitto, ignored

But the warning is very easy to miss, I missed it myself.

mfalkvidd commented 2 years ago

@piotrraczynski have you had a chance to verify the suggested solution?

mfalkvidd commented 2 years ago

Closing due to inactivity and what (probably) was a configuration error. Feel free to reopen.