MySensors icon indicating copy to clipboard operation
MySensors copied to clipboard

RPI mqtt gateway not working with user/password authentication

Open piotrraczynski opened this issue 2 years ago • 6 comments

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 avatar Mar 27 '22 21:03 piotrraczynski

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.

piotrraczynski avatar Mar 28 '22 09:03 piotrraczynski

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?

mfalkvidd avatar Apr 01 '22 19:04 mfalkvidd

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: @.***>

piotrraczynski avatar Apr 01 '22 20:04 piotrraczynski

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

mfalkvidd avatar Apr 02 '22 07:04 mfalkvidd

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 avatar Apr 02 '22 07:04 mfalkvidd

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

mfalkvidd avatar Apr 10 '22 05:04 mfalkvidd

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

mfalkvidd avatar Aug 28 '22 12:08 mfalkvidd