I am trying to run aiomqtt on Windows platform but getting NotImplementedError upon usage.
The code I'm using is as-is from documentation
import asyncio
import aiomqtt
async def main():
async with aiomqtt.Client("test.mosquitto.org") as client:
await client.publish("temperature/outside", payload=28.4)
asyncio.run(main())
The error is as follows in the terminal
Exception in callback AbstractEventLoop.add_reader(764, <function Cli...00218E19C0360>)
handle: <Handle AbstractEventLoop.add_reader(764, <function Cli...00218E19C0360>)>
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..., 1883, 0, 0)>, <function Cli...00218E19C1B20>)
handle: <Handle AbstractEventLoop.add_writer(<socket.socke..., 1883, 0, 0)>, <function Cli...00218E19C1B20>)>
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
NotImplementedError
Traceback (most recent call last):
File "D:\mango\test.py", line 10, in <module>
asyncio.run(main())
File "C:\Program Files\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "D:\mango\test.py", line 6, in main
async with aiomqtt.Client("test.mosquitto.org") as client:
File "D:\mango\venv\Lib\site-packages\aiomqtt\client.py", line 731, in __aenter__
await self._wait_for(self._connected, timeout=None)
File "D:\mango\venv\Lib\site-packages\aiomqtt\client.py", line 502, in _wait_for
raise MqttError(msg) from None
aiomqtt.exceptions.MqttError: Operation timed out
Caught exception in on_socket_unregister_write:
Exception ignored in: <function Client.__del__ at 0x00000218E19AAAC0>
Traceback (most recent call last):
File "D:\mango\venv\Lib\site-packages\paho\mqtt\client.py", line 880, in __del__
File "D:\mango\venv\Lib\site-packages\paho\mqtt\client.py", line 1139, in _reset_sockets
File "D:\mango\venv\Lib\site-packages\paho\mqtt\client.py", line 1131, in _sock_close
File "D:\mango\venv\Lib\site-packages\paho\mqtt\client.py", line 2976, in _call_socket_unregister_write
File "D:\mango\venv\Lib\site-packages\aiomqtt\client.py", line 697, in _on_socket_unregister_write
File "C:\Program Files\Python311\Lib\asyncio\events.py", line 539, in remove_writer
NotImplementedError:
However this same code ran without any problem in Ubuntu 24.02 (Window WSL). Verified by multiple publish / subscribe to both localhost and test.mosquitto.org.
In both cases, the python version is 3.12 and aiomqtt is 2.3.0
The mqtt broker service installed in system in Windows is Mosquitto and other application using simple paho-mqtt in Python and mosquitto in C++ are working correctly for both localhost:1883 and test.mosquitto.org
Could this be a platform issue? My current OS is Windows 11 Home 23H2 (22631.4037)
I am trying to run aiomqtt on Windows platform but getting NotImplementedError upon usage. The code I'm using is as-is from documentation
The error is as follows in the terminal
However this same code ran without any problem in Ubuntu 24.02 (Window WSL). Verified by multiple publish / subscribe to both localhost and test.mosquitto.org.
In both cases, the python version is 3.12 and aiomqtt is 2.3.0
The mqtt broker service installed in system in Windows is Mosquitto and other application using simple paho-mqtt in Python and mosquitto in C++ are working correctly for both localhost:1883 and test.mosquitto.org
Could this be a platform issue? My current OS is Windows 11 Home 23H2 (22631.4037)
Thank you for your time to read this issue :)