Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Connection refused #42

Open
mconlow opened this issue Feb 5, 2020 · 2 comments
Open

Connection refused #42

mconlow opened this issue Feb 5, 2020 · 2 comments

Comments

@mconlow
Copy link

mconlow commented Feb 5, 2020

I'm using the Northfifteen Connected Home Plant Monitor because I read it runs the same firmware as the Xiaomi miflora, and those have become hard to find.

I have plantgateway running on a Raspberry Pi Zero W. It seems to find my plant monitor because sudo hcitool lescan find the mac address with "Flower care" as the name.

However when I run plantgateway I get ConnectionRefusedError: [Errno 111] Connection refused

Any thoughts? Is my hardware actually compatible?

@ChristianKuehnel
Copy link
Owner

Where is that exception coming from? From the Bluetooth stack? Or from mqtt? Maybe you can attach the stack trace?

@justin8
Copy link

justin8 commented Feb 9, 2020

I was getting the same thing. It's a bit of a misleading error. It says "could not read data from ..." as though it couldn't connect to the bluetooth device. But in reality the stack trace shows it is covering up the actual error in the mqtt client.

Slightly related, but I only found this because the default port is 8883 which is MQTT over TLS; even when it's connecting without TLS enabled, plantgateway is defaulting to 8883 instead of 1883

Sun, 09 Feb 2020 02:28:18 ERROR    could not read data from C4:7C:8D:6A:AD:63 (FrontPotPlant) with reason: [Errno 111] Connection refused
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 263, in process_all
    self.process_mac(sensor)
  File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 240, in process_mac
    self.announce_sensor(sensor_config)
  File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 286, in announce_sensor
    self.start_client()
  File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 183, in start_client
    self._start_client()
  File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 205, in _start_client
    self.mqtt_client.connect(self.config.mqtt_server, self.config.mqtt_port, 60)
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1071, in reconnect
    sock = self._create_socket_connection()
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3522, in _create_socket_connection
    return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
  File "/usr/lib/python3.7/socket.py", line 727, in create_connection
    raise err
  File "/usr/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused```


Pretty sure you should be able to just change this line: https://github.com/ChristianKuehnel/plantgateway/blob/1be6d51a7193134db50bfc23a7d460e65dd6f5df/plantgw/plantgw.py#L265

To have an `except ConnectionRefusedError as e:` and handle a nice error about mqtt failures there?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants