MQTT connection with username/password
wifi75 opened this issue · 17 comments
Hello My weewx send data to my mqt tserver,
my broker have usr and password.
as skyn.conf missing line for set mqtt user and password,
in fact skyn does not connect to mqtt to collect the data and generate the gauge.
this is my mqtt sky configurazion
For instructions, see https://github.com/Daveiano/weewx-wdc/wiki/Support-for-weewx-mqtt
[[mqtt]]
mqtt_websockets_enabled = 1
mqtt_websockets_host = "192.168.1.52"
mqtt_websockets_port = 1884
mqtt_websockets_ssl = 0
mqtt_websockets_topic = "weather/loop"
How should I add a user and password?
The skin currently only supports connecting anonymously to the MQTT broker, without a username and password.
I was not aware of people using credentials on the client side, since they are exposed to the public.
I will add this in the next release, please be patient!
My Broker on Home assistant is configured with user name and password...
ok I will wait for the new version
Thank you
hello, how I Can try?
I released a pre-release, v3.5.0-alpha1, for you to test this out. Please follow the normal update instructions.
You can now set mqtt_websockets_username
and mqtt_websockets_password
in skin.conf, see https://github.com/Daveiano/weewx-wdc/blob/3.x/skins/weewx-wdc/skin.conf#L45
Ok, that's difficult for me without something to look at.
Some ideas:
- You are using a local IP, I assume the skin is hosted in that same network and has access to the specified IP?
- Do you have any idea which MQTT version you are using (MQTTv3.1.1 vs MQTTv3.1)
- In the Browser open the Console (via F12 for most browsers, more info here https://screenful.com/guide/how-to/how-to-open-the-browser-developer-console). In the console you should see an error message?
What is the error saying?
broker have static ip and my broker it is inatalled on Home assistant
https://github.com/home-assistant/addons/tree/master/mosquitto
From the screenshot, it looks like you are using secure websockets via SSL (wss://...). Your home assistant config uses non-secure (ws://...) connection on port 1884.
So you should either use
mqtt_websockets_port = 1884
mqtt_websockets_ssl = 0
or
mqtt_websockets_port = 8884
mqtt_websockets_ssl = 1
broker have static ip and my broker it is inatalled on Home assistantbroker have static ip and my broker it is inatalled on Home assistant
Please correct me if I am wrong but the skin has no access to 192.168.1.52! If I am accessing https://meteo.iu3cyv.eu/weewx/ I have no access to YOUR local IP. The only way this could work is when you are accessing the skin in the same network as your Home assistant is operating.
Please let me know if this helps you, you should inform yourself about the differences between Local/Private IPs vs Public IP addresses.
hello Daveiano nothing you wrote to me is correct,
broker mqtt and meteo weewx server they are on the same local network, weewx reaches the mqtt broker easily!
in the skin configuration I am using the non-secure websocket on port 1884, in fact I configured it like this:
mqtt_websockets_ssl = 0
First of all, I just re-configured my MQTT Broker to use a username & password for read access and it works. So the general implementation works.
in the skin configuration I am using the non-secure websocket on port 1884, in fact I configured it like this:
mqtt_websockets_ssl = 0
Perhaps you configured something in weewx.conf ([StdReport][[WdcReport]]
)? Configurations in weewx.conf have a higher priority than configs in skin.conf. The screenshot clearly proves that your page tries to connect via secure websockets (wss):
hello Daveiano nothing you wrote to me is correct,
broker mqtt and meteo weewx server they are on the same local network, weewx reaches the mqtt broker easily!
I think I was not clear about this: It's not weewx, which subscribes to the MQTT broker, it's the browser (the client). Again: If I visit https://meteo.iu3cyv.eu/weewx/, my Browser will have NO access to any of your local IPs. This will only work if you visit the page in the same network as your Broker lives.
SOrry but what is th correct skin configuration for connect without ssl?
mqtt_websockets_ssl = 0
should do it. Does it not work?
mqtt_websockets_ssl = 0
should do it. Does it not work?
in my configuration, as you can see from the screenshots it is already at 0 but I don't understand why it connects to wss from the chrome console..
why do you think?
Could you please check if there are mqqt skin settings defined in weewx.conf? Like I said in a previous comment:
Perhaps you configured something in weewx.conf ([StdReport][[WdcReport]])?
I did some research and found out that the MQTT Client first tries to connect via the specified protocol (without SSL) and if that fails it tries to connect the other option (with SSl in that case) - so it seems this is normal behaviour because the connection is failing.
Any news on the IPs? My simple guess is that your broker is not reachable by the MQTT Client (Browser).
my broker can be reached by clients.
in weewx.conf I don't have any mqtt skin configuration.
However, I'm waiting for the new version of homeassistant which will be released at the beginning of December. it seems the current one doesn't accept mqtt websocket. We see....
I will keep you updated
Ok, good news! Thank you!