Comments (4)
hi @empicano ,
thanks for your answer!
You can set custom identifiers for each client instance by setting the client's
identifier
parameter on initialization. This way we know which one failed π
Nice, I will use it!
[...] Going by your pseudo code, I would assume that when one client errors, all others should disconnect as well.
Right... that was my design criteria... the idea is that a client will get an error presumably in case of some network issue, and it's likely the network issue will impact all clients at the same time, since they run from the same application, same compute node.
So that's why I catch the aiomqtt.MqttError outside all tasks.
As that doesn't seem to be the case, the exception is probably handled somewhere inside the task.
The thing is: in my (short) software there 1 single "except* aiomqtt.MqttError"... nor there is any "catch all" except statement.
So if I see a log of a (unexpected) client disconnection in the mosquitto logs, I was expecting that my "except* aiomqtt.MqttError" code block was executed... I still cannot figure out why it's not.
By default, aiomqtt doesn't reconnect. You can however configure reconnection as described in the documentation.
Ok good to know. Indeed my code was written using that reconnection page as reference...
thanks I will update if/when this problem happens again. Today I had to stop and restart my application several times so I cannot say from mosquitto logs if there is any unexpected disconnection.
from aiomqtt.
Hi Francesco,
That's nice to hear that you like aiomqtt π
Let's try to solve this together! You say that you have four aiomqtt.Client
instances, but don't know which one is the guilty one. Your mosquitto logs include the client identifier "6oWlj6DunsNKB3a3cjBthG", which I assume was automatically generated. You can set custom identifiers for each client instance by setting the client's identifier
parameter on initialization. This way we know which one failed π
Apart from that, the asyncio documentation on TaskGroups states that "The first time any of the tasks belonging to the group fails with an exception other than asyncio.CancelledError
, the remaining tasks in the group are cancelled". Going by your pseudo code, I would assume that when one client errors, all others should disconnect as well. As that doesn't seem to be the case, the exception is probably handled somewhere inside the task. By default, aiomqtt doesn't reconnect. You can however configure reconnection as described in the documentation.
Let me know if that helps π
from aiomqtt.
Hi @empicano , hi all,
Thanks to the suggestion of using a custom-defined identifier, I've been able to understand that when I see in mosquitto broker a line like that:
2024-03-05T02:54:33: New connection from 192.168.1.5:46764 on port 1883.
2024-03-05T02:54:33: New client connected from 192.168.1.5:46764 as 6oWlj6DunsNKB3a3cjBthG (p2, c1, k60).
it does NOT mean that the client IP address is 192.168.1.5. 192.168.1.5 is the IP address of the Mosquitto broker. Actually I discovered these client connections do not come from my own software (which now uses human-friendly identifiers for clients) but rather from Home Assistant.
So the problem is not in my application written using aiomqtt.
I'm closing this ticket then. Thanks for your support!!
from aiomqtt.
Great detective work, and thanks for reporting back! π
from aiomqtt.
Related Issues (20)
- Pin Paho to <2.0 HOT 2
- Make aiomqtt compatible with paho v2 HOT 10
- Topic.matches should be used when doing == HOT 4
- How to get the IP of a failed connection attempt
- strange reconnection HOT 2
- 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
- Can't read incoming messages in pytests HOT 8
- 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
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.