I’ll make a wild guess and hypothesize that the problem is that the weewx MQTT module is trying to speak TLS to the broker on port 1883 rather than 8883. I would start by getting MQTT working without TLS — just remove the “[[[tls]]]” section from weewx.conf. Once that is working you can add TLS back, but usually there’s no advantage to encrypting network traffic to localhost.
-Les > On 16 Mar 2021, at 10:56, Carlo <[email protected]> wrote: > > Hi everyone. I have a problem with the MQTT Broker on my localhost server. > My website (meteopievedicampo.ddns.net) work good, but i wanto to enable MQTT. > I open on my firewall the 9001 port. > > I have this error in mosquitto log: > ------------------------------------------------------------------------------------------- > 1615760009: New connection from 127.0.0.1 on port 1883. > 1615760009: Client <unknown> disconnected due to protocol error. > 1615760060: New client connected from ::ffff:192.168.1.2 as website557173374 > (p2, c1, k60). > 1615760060: New connection from 127.0.0.1 on port 1883. > 1615760060: Client <unknown> disconnected due to protocol error > --------------------------------------------------------------------------------------------- > > and this is syslog: > --------------------------------------------------------------------------------------------- > DEBUG user.mqtt: Failed upload attempt 3: [Errno 104] Connessione interrotta > dal corrispondente > ERROR weewx.restx: MQTT: Failed to publish record 2021-03-14 23:18:23 CET > (1615760303): Failed upload after 3 tries > --------------------------------------------------------------------------------------------- > > This is my weewx.conf: > > --------------------------------------------------------------------------------------------- > [[MQTT]] > server_url = mqtt://carlo:XXXXXXXXX@localhost:1883/ > topic = weather/loop > unit_system = METRIC > binding = archive, loop > aggregation = aggregate > [[[tls]]] > tls_version = tlsv12 > ca_certs = /etc/mosquitto/certs/chain.pem > > # MQTT Websockets defaults > mqtt_websockets_enabled = 1 > mqtt_websockets_host = meteopievedicampo.ddns.net > mqtt_websockets_port = 9001 > mqtt_websockets_ssl = 1 > mqtt_websockets_topic = weather/loop > disconnect_live_website_visitor = 1800000 > > [MQTTSubscribeService] > enable = true > host = localhost > port = 1883 > keepalive = 60 > username = carlo > password = XXXXXXXXXX > binding = loop > [[message_callback]] > type = json > [[topics]] > unit_system = METRIC > ------------------------------------------------------------------------------------------- > > And this is my mosquitto.conf: > > ------------------------------------------------------------------------------------------ > persistence false > allow_anonymous true > password_file /etc/mosquitto/passwd > acl_file /etc/mosquitto/acl > # Insecure mqtt to localhost only, and secure mqtt > listener 1883 localhost > listener 8883 > certfile /etc/mosquitto/certs/cert.pem > cafile /etc/mosquitto/certs/chain.pem > keyfile /etc/mosquitto/certs/privkey.pem > protocol mqtt > # websockets > listener 9001 > certfile /etc/mosquitto/certs/cert.pem > cafile /etc/mosquitto/certs/chain.pem > keyfile /etc/mosquitto/certs/privkey.pem > protocol websockets > ------------------------------------------------------------------------------------------------------ > > Thanks everyone help me! > Carlo > > -- > You received this message because you are subscribed to the Google Groups > "weewx-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/bd2362e9-95fd-4d0b-9aa8-eb0abea25350n%40googlegroups.com > > <https://groups.google.com/d/msgid/weewx-user/bd2362e9-95fd-4d0b-9aa8-eb0abea25350n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/6224C3EC-947A-4F0C-BE51-7EA9B2B2453E%402pi.org.
