sbtinstruments / aiomqtt

The idiomatic asyncio MQTT client, wrapped around paho-mqtt
https://sbtinstruments.github.io/aiomqtt
BSD 3-Clause "New" or "Revised" License
392 stars 71 forks source link

connection doesn't work on python 3.12 on windows(VSC)? #265

Closed DarioKTS closed 5 months ago

DarioKTS commented 5 months ago

Trying just this:

import asyncio
import aiomqtt
async def main():
    async with aiomqtt.Client("test.mosquitto.org") as client:
        async with client.messages() as messages:
            await client.subscribe("humidity/#")
            async for message in messages:
                print(message.payload)

#-- - ---- ----and the name is-->     
if __name__ == "__main__":
    asyncio.run(main())

or swapping out "test.mosquitto.org" with the crerdentials for my local mosuitto instance returns a timeout error message.

The relevant bits of info are:

Exception in callback AbstractEventLoop.add_reader(1028, <function Cli...001B19A0B16C0>)
handle: <Handle AbstractEventLoop.add_reader(1028, <function Cli...001B19A0B16C0>)>
Exception in callback AbstractEventLoop.add_writer(<socket.socke...93.94', 1883)>, <function Cli...001B19A0B1BC0>)
handle: <Handle AbstractEventLoop.add_writer(<socket.socke...93.94', 1883)>, <function Cli...001B19A0B1BC0>)>
Traceback (most recent call last):
  File "C:\...\Python312\Lib\asyncio\events.py", line 84, in _run
    self._context.run(self._callback, *self._args)
  File "C:\...\Python312\Lib\asyncio\events.py", line 534, in add_reader
    raise NotImplementedError

I've created a venv with 3.11.7, but it didn't make a difference.

handle: <Handle AbstractEventLoop.add_reader(828, <function Cli...002280436AB60>)>
Traceback (most recent call last):
  File "C:\Program Files\Python311\Lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Program Files\Python311\Lib\asyncio\events.py", line 530, in add_reader
    raise NotImplementedError
NotImplementedError
Exception in callback AbstractEventLoop.add_writer(<socket.socke...93.94', 1883)>, <function Cli...002280436AFC0>)
handle: <Handle AbstractEventLoop.add_writer(<socket.socke...93.94', 1883)>, <function Cli...002280436AFC0>)>
Traceback (most recent call last):
  File "C:\Program Files\Python311\Lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Program Files\Python311\Lib\asyncio\events.py", line 536, in add_writer
    raise NotImplementedError

Am i getting something worng? Happy to learn if so. Otherwise- on which version of python should i be for aiomqtt to work properly? should i be on debian?

DarioKTS commented 5 months ago

sorry i'v eseen now the note regarding the proactor/selector event loop