spacemanspiff2007 / sml2mqtt

Sml to MQTT Bridge
GNU General Public License v3.0
25 stars 8 forks source link

AttributeError: 'Client' object has no attribute '_sock' #38

Closed qqq4000 closed 4 months ago

qqq4000 commented 4 months ago

Hi,

I have been using sml2mqtt for quite some time now without any issues. But recently I had to reinstall my system and therefore upgraded to the latest version. Unfortunately I cant get it to run with the latest version 2.2.

I installed sml2mqtt according the instruction for a venv and I am also able to get a basic sml frame by using

sml2mqtt -c config.ini -a

But when I try to launch it, the following error appears:

Traceback (most recent call last):
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 874, in __del__
    self._reset_sockets()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._sock_close()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
    if not self._sock:
AttributeError: 'Client' object has no attribute '_sock'

I am using a Raspberry Pi ZeroW with Raspbian 11.

Any idea how this can be fixed?

spacemanspiff2007 commented 4 months ago

Does it properly install the dependencies? How do you make both calls?

qqq4000 commented 4 months ago

I think so, yes.

(venv) pi@raspberrypi:/opt/sml2mqtt $ python -m pip install -r requirements_setup.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: asyncio-mqtt==0.16.1 in ./venv/lib/python3.9/site-packages (from -r requirements_setup.txt (line 1)) (0.16.1)
Requirement already satisfied: pyserial-asyncio==0.6 in ./venv/lib/python3.9/site-packages (from -r requirements_setup.txt (line 2)) (0.6)
Requirement already satisfied: easyconfig==0.2.8 in ./venv/lib/python3.9/site-packages (from -r requirements_setup.txt (line 3)) (0.2.8)
Requirement already satisfied: pydantic<2.0,>=1.10 in ./venv/lib/python3.9/site-packages (from -r requirements_setup.txt (line 4)) (1.10.14)
Requirement already satisfied: smllib==1.2 in ./venv/lib/python3.9/site-packages (from -r requirements_setup.txt (line 5)) (1.2)
Requirement already satisfied: paho-mqtt>=1.6.0 in ./venv/lib/python3.9/site-packages (from asyncio-mqtt==0.16.1->-r requirements_setup.txt (line 1)) (2.0.0)
Requirement already satisfied: typing-extensions>=4.4.0 in ./venv/lib/python3.9/site-packages (from asyncio-mqtt==0.16.1->-r requirements_setup.txt (line 1)) (4.9.0)
Requirement already satisfied: pyserial in ./venv/lib/python3.9/site-packages (from pyserial-asyncio==0.6->-r requirements_setup.txt (line 2)) (3.5)
Requirement already satisfied: ruamel.yaml<0.18,>=0.17 in ./venv/lib/python3.9/site-packages (from easyconfig==0.2.8->-r requirements_setup.txt (line 3)) (0.17.40)
Requirement already satisfied: ruamel.yaml.clib>=0.2.7 in ./venv/lib/python3.9/site-packages (from ruamel.yaml<0.18,>=0.17->easyconfig==0.2.8->-r requirements_setup.txt (line 3)) (0.2.8)

but I still get:

(venv) pi@raspberrypi:/opt/sml2mqtt $ sml2mqtt -c config.ini
Exception ignored in: <function Client.__del__ at 0xb5b72898>
Traceback (most recent call last):
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 874, in __del__
    self._reset_sockets()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._sock_close()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
    if not self._sock:
AttributeError: 'Client' object has no attribute '_sock'
Exception ignored in: <function Client.__del__ at 0xb5b72898>
Traceback (most recent call last):
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 874, in __del__
    self._reset_sockets()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._sock_close()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
    if not self._sock:
AttributeError: 'Client' object has no attribute '_sock'
Exception ignored in: <function Client.__del__ at 0xb5b72898>
Traceback (most recent call last):
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 874, in __del__
    self._reset_sockets()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._sock_close()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
    if not self._sock:
AttributeError: 'Client' object has no attribute '_sock'
Shutting down ...

For the initial setup I followed: https://sml2mqtt.readthedocs.io/en/latest/installation.html#virtual-environment

spacemanspiff2007 commented 4 months ago

Can you downgrade paho to 1.6.1? That should fix the isse pip install paho-mqtt==1.6.1

qqq4000 commented 4 months ago

Great, works perfectly! I previously tinkered around with the revision of the asyncio-mqtt to fix this, but forgot about the paho-mqtt package. So thank you very much for your help.