Comments (8)
It turned out that everything was fine, pytest doesn't print by default.
I'm sorry for the inconvenience
from aiomqtt.
Hi Waganama, thanks for opening this issue. π Let me have a look. :)
It looks like you subscribe to these topics:
f"mqtt/things/{device}/uplink"
but you post messages to this topic (where device
is the last entry in devices
):
f"mqtt/things/{device}/downlink"
Since the topics don't match, you'll never receive a message. That explains why it gets "stuck": There are no messages in wait.
As a test, try to subscribe to everything: "mqtt/things/#"
. See if that works. :)
from aiomqtt.
Thank you for your response.
I have two topics, one to send downlink (client->server) and one to received uplink (server->client)
I still tried to change the topic for my subscribtion, without success.
It looks like that calling yield task.result()
doesn't do anything when running with pytest.
I'm also sure that i received message according to these logs i had:
DEBUG aiomqtt:client.py:618 _on_message _queue size after put 1
DEBUG aiomqtt:client.py:474 _messages yield task.result()
DEBUG aiomqtt:client.py:463 _messages _queue size after get 0
I tried to run the same code above without pytest, and it worked perfectly, I can read my message.
from aiomqtt.
Thanks for the response. This is really difficult to debug without the full code. Do you have self-sufficient example code that reproduces the problem?
from aiomqtt.
I reduce the test part to reproduce the issue only. It is a very simple test.
Unfortunatly I can't share connection information and i don't know if there are mqtt server dedicated for test.
I hope will have everything to debug.
from aiomqtt.
After research, i found out i can use the server test.mosquitto.org for my test. I also have the same issue withe the following code using pytest.
Output :
configfile: pytest.ini
plugins: anyio-3.7.0, asyncio-0.21.0
asyncio: mode=Mode.AUTO
collected 2 items
tests/test_mosquitto.py::TestMosquitto::test_mosquitto[asyncio]
--------------------------------------------------- live log setup ----------------------------------------------------
DEBUG asyncio:selector_events.py:54 Using selector: SelectSelector
---------------------------------------------------- live log call ----------------------------------------------------
INFO root:test_mosquitto.py:37 Here
DEBUG aiomqtt:client.py:3254 Sending CONNECT (u0, p0, wr0, wq0, wf0, c1, k60) client_id=b''
DEBUG aiomqtt:client.py:3254 Received CONNACK (0, 0)
DEBUG aiomqtt:client.py:3254 Sending SUBSCRIBE (d0, m1) [(b'win32_3.11/tests/aiomqtt/test_client_unsubscribe/1', 0)]
DEBUG aiomqtt:client.py:3254 Received SUBACK
DEBUG aiomqtt:client.py:3254 Sending PUBLISH (d0, q0, r0, m2), 'b'win32_3.11/tests/aiomqtt/test_client_unsubscribe/1'', ... (12 bytes)
DEBUG aiomqtt:client.py:463 _messages _queue size after get 0
DEBUG aiomqtt:client.py:3254 Received PUBLISH (d0, q0, r0, m0), 'win32_3.11/tests/aiomqtt/test_client_unsubscribe/1', ... (12 bytes)
DEBUG aiomqtt:client.py:618 _on_message _queue size after put 1
DEBUG aiomqtt:client.py:474 _messages yield task.result().topic : win32_3.11/tests/aiomqtt/test_client_unsubscribe/1
DEBUG aiomqtt:client.py:463 _messages _queue size after get 0
from aiomqtt.
I have additionnal informations, if i have different behaviour according how I run my test :
- python -m pytest tests\test_mosquitto.py -> No message is printed after the async for loop
- python -m pytest --capture=no tests\test_mosquitto.py -> Message are printed
I don't know why the capture=no has effect.
from aiomqtt.
No problem. π Glad that it worked out in the end!
from aiomqtt.
Related Issues (20)
- How to get the IP of a failed connection attempt
- strange reconnection HOT 2
- MQTT broker reports a disconnection/reconnection... but no aiomqtt.MqttError is raised HOT 4
- Exceptions on __aenter__ not handled. HOT 2
- Reconnect Bug HOT 1
- Cannot instantiate a client due to internal mqtt problem HOT 2
- Issues with uvicorn on Windows 10 HOT 5
- [BUG] Cannot install version 2.0.0 with paho-mqtt 2.0.0 HOT 2
- [BUG] 127.0.0.1/localhost Work Incorrectly HOT 3
- Do not send messages for a long time mqtt automatically disconnects HOT 2
- No convenient way to get message without getting locked into a for loop HOT 2
- Can aiomqtt queue has a ring buffer optionοΌ for high frequense in-comming messages? HOT 1
- Is it necessary to support mqtt connection pool? HOT 1
- Operation timed out HOT 2
- DeprecationWarning: HOT 1
- Add optional dependency for PySocks to support proxy
- aiomqtt client_id HOT 2
- [Request] AnyIO compatibility HOT 1
- FastAPI Shared Client Connection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiomqtt.