OK, that produced some interesting results.  For your first suggestion, my 
broker computer is running Hass.io (Home Assistant), which doesn't have the 
ss command.  I'll keep digging there to see if there's another way to 
double check that the port is open, but the log seems to indicate it's 
listening on 1883.  

I installed  mosquitto-clients on a raspberry pi that I'm not using for 
Weewx or my broker.  So far everything I try there results in the same 
connection refused error.  I've tried both as anonymous and as a user.  
Here's an example of an attempt:
pi@piopolis:~ $ mosquitto_sub -h 192.168.1.35 -t test -u homeassistant -P 
reallylongpassword
Error: Connection refused

Checking the log on the broker, I see no evidence of the attempt, which 
would point to the port not actually being open.  But then I try to connect 
from my windows machine using MQTT Explorer and everything works.  I can 
publish messages and see them pop up on my broker machine.  The log looks 
normal.  

*MQTT Explorer setup:*
[image: Capture.PNG]

*Logs from mosquitto broker:*
[22:30:06] INFO: Setup mosquitto configuration 
[22:30:06] WARNING: SSL not enabled - No valid certs found! 
[22:30:06] INFO: No local user available 
[22:30:07] INFO: Initialize Hass.io Add-on services 
[22:30:07] INFO: Initialize Home Assistant discovery [22:30:07] INFO: Start 
Mosquitto daemon 
1611639007: mosquitto version 1.6.3 starting 
1611639007: Config loaded from /etc/mosquitto.conf. 
1611639007: Loading plugin: /usr/share/mosquitto/auth-plug.so 
1611639007: |-- *** auth-plug: startup 
1611639007: ├── Username/password checking enabled. 
1611639007: ├── TLS-PSK checking enabled. 
1611639007: └── Extended authentication not enabled. 
1611639007: Opening ipv4 listen socket on port 1883. 
1611639007: Opening ipv6 listen socket on port 1883. 
1611639007: Opening websockets listen socket on port 1884. 
1611639007: Warning: Mosquitto should not be run as root/administrator. 
1611639012: New connection from 172.30.32.1 on port 1883. [INFO] found 
homeassistant on local database 
1611639012: New client connected from 172.30.32.1 as 5yoX9kmQROmBbxG2B0yAct 
(p2, c1, k60, u'homeassistant'). 
1611639366: New connection from 192.168.1.185 on port 1883. [INFO] found 
homeassistant on local database 
1611639366: New client connected from 192.168.1.185 as 
mqtt-explorer-a18267b6 (p2, c1, k60, u'homeassistant').  

On Monday, January 25, 2021 at 9:11:59 PM UTC-7 vince wrote:

> Connection refused usually means the other side literally not listening on 
> that port.  You might want to check that 192.168.1.35 is listening on port 
> 1883.  That should be the ip address of your MQTT broker, not the ip 
> address of the weewx system that's trying to connect to it.
>
> Here's me checking my MQTT server pi
>
> pi@pi3:~ $ sudo ss -tupl|grep 1883
> tcp   LISTEN 0      100                         0.0.0.0:1883           
>  0.0.0.0:*                      users:(("mosquitto",pid=607,fd=5))
> tcp   LISTEN 0      100                            [::]:1883               
> [::]:*                      users:(("mosquitto",pid=607,fd=6))
>
> ...and checking that process 607 is the MQTT server...
>
> pi@pi3:~ $ ps -aux|grep 607
> mosquit+   607  0.0  0.5   8924  5128 ?        Ss   Jan12   7:49 
> /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
>
>
> Quick test with mosquitto is to get on a client computer and run:
> mosquitto_sub -h 192.168.1.35 -t testingmqtt
>
> And in another window send a message to that topic:
> mosquitto_pub -h 192.168.35 -t testingmqtt -m hellothere
>
> (and the first window that's subscribing should display the 'hellothere' 
> message the other window sent to the broker)
>
> On Monday, January 25, 2021 at 7:53:02 PM UTC-8 [email protected] 
> wrote:
>
>> I'm having trouble getting data into Home Assistant via MQTT.  I've 
>> connected to Home Assistant with MQTT Explorer and been able to publish to 
>> a test topic, so that end of things appears to be working.  
>>
>> I did my best to follow the instructions at 
>> https://github.com/weewx/weewx/wiki/mqtt, skipping the python-cjson 
>> since weewx is using python 3 (via Deb package).  The MQTT portion of my 
>> weewx.config looks like this in my latest attempt:
>>     [[MQTT]]
>>         server_url = mqtt://192.168.1.35:1883
>>         topic = weather
>>         unit_system=METRIC
>>         [[[inputs]]]
>>             [[[[inTemp]]]]
>>                 units = degree_F
>>
>> Initially I was trying with server_url = mqtt://
>> user:[email protected]:1883 <http://user:[email protected]:1883>, 
>> but recently enabled anonymous connections in case a password typo was the 
>> problem.  
>>
>> With debug = 1 my syslog seems to indicate the problem is possibly with 
>> authentication (connection refused).  Any ideas what I'm doing wrong.
>>
>> Jan 25 20:39:49 raspberrypi weewx[29660] DEBUG weewx.drivers.acurite: 
>> Found station at bus= device=
>> Jan 25 20:39:49 raspberrypi weewx[29660] DEBUG weewx.drivers.acurite: 
>> next read in 18 seconds
>> Jan 25 20:40:01 raspberrypi CRON[1952]: (pi) CMD (python3 
>> /home/pi/cron_jobs/humid_checker.py > /dev/null)
>> Jan 25 20:40:07 raspberrypi weewx[29660] DEBUG weewx.drivers.acurite: 
>> Found station at bus= device=
>> Jan 25 20:40:07 raspberrypi weewx[29660] DEBUG weewx.drivers.acurite: 
>> next read in 12 seconds
>> Jan 25 20:40:19 raspberrypi weewx[29660] DEBUG weewx.drivers.acurite: 
>> Found station at bus= device=
>> Jan 25 20:40:19 raspberrypi /weewxd: inside humid: found value of 53.2
>> Jan 25 20:40:19 raspberrypi weewx[29660] INFO weewx.manager: Added record 
>> 2021-01-25 20:40:00 MST (1611632400) to database 'weewx.sdb'
>> Jan 25 20:40:19 raspberrypi weewx[29660] INFO weewx.manager: Added record 
>> 2021-01-25 20:40:00 MST (1611632400) to daily summary in 'weewx.sdb'
>> Jan 25 20:40:22 raspberrypi weewx[29660] DEBUG weewx.reportengine: 
>> Running reports for latest time in the database.
>> Jan 25 20:40:22 raspberrypi weewx[29660] DEBUG weewx.reportengine: 
>> Running report 'StandardReport'
>> Jan 25 20:40:22 raspberrypi weewx[29660] DEBUG user.mqtt: Failed upload 
>> attempt 1: [Errno 111] Connection refused
>> Jan 25 20:40:23 raspberrypi weewx[29660] DEBUG weewx.drivers.acurite: 
>> Found station at bus= device=
>> Jan 25 20:40:23 raspberrypi weewx[29660] DEBUG weewx.drivers.acurite: 
>> next read in 6 seconds
>> Jan 25 20:40:23 raspberrypi weewx[29660] DEBUG weewx.reportengine: Found 
>> configuration file /etc/weewx/skins/Seasons/skin.conf for report 
>> 'StandardReport'
>> Jan 25 20:40:23 raspberrypi weewx[29660] DEBUG weewx.cheetahgenerator: 
>> Using search list ['weewx.cheetahgenerator.Almanac', 
>> 'weewx.cheetahgenerator.Station', 'weewx.cheetahgenerator.Current', 
>> 'weewx.cheetahgenerator.Stats', 'weewx.cheetahgenerator.UnitInfo', 
>> 'weewx.cheetahgenerator.Extras']
>> Jan 25 20:40:23 raspberrypi weewx[29660] DEBUG weewx.manager: Daily 
>> summary version is 3.0
>> Jan 25 20:40:27 raspberrypi weewx[29660] DEBUG user.mqtt: Failed upload 
>> attempt 2: [Errno 111] Connection refused
>> Jan 25 20:40:29 raspberrypi weewx[29660] DEBUG weewx.drivers.acurite: 
>> Found station at bus= device=
>> Jan 25 20:40:29 raspberrypi weewx[29660] DEBUG weewx.drivers.acurite: 
>> next read in 18 seconds
>> Jan 25 20:40:32 raspberrypi weewx[29660] DEBUG user.mqtt: Failed upload 
>> attempt 3: [Errno 111] Connection refused
>> Jan 25 20:40:35 raspberrypi weewx[29660] INFO weewx.cheetahgenerator: 
>> Generated 8 files for report StandardReport in 12.36 seconds
>> Jan 25 20:40:35 raspberrypi weewx[29660] DEBUG weewx.manager: Daily 
>> summary version is 3.0
>> Jan 25 20:40:37 raspberrypi weewx[29660] ERROR weewx.restx: MQTT: Failed 
>> to publish record 2021-01-25 20:40:00 MST (1611632400): Failed upload after 
>> 3 tries
>> Jan 25 20:40:42 raspberrypi weewx[29660] INFO weewx.imagegenerator: 
>> Generated 14 images for report StandardReport in 6.25 seconds
>> Jan 25 20:40:42 raspberrypi weewx[29660] INFO weewx.reportengine: Copied 
>> 0 files to /var/www/html/weewx
>>
>

-- 
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/9a9995f0-6283-4ea8-8e2c-550fd6972a1fn%40googlegroups.com.

Reply via email to