Reconnection in fastapi #240
Unanswered
tomliptrot
asked this question in
Q&A
Replies: 1 comment 7 replies
-
Hi Tom, This is a good discussion to have, aiomqtt needs improvement in this sense 🙂 To address your questions:
The tricky thing is that with FastAPI we can't go back into the lifespan function (or want to for that matter; there's potentially other expensive stuff that's initialized there, like a database pool). I think the best way would be to implement reconnection directly in aiomqtt such that it's automatic (e.g. like a database pool). For context, PR #216 made the context manager reusable and issue #6 has some background on reconnection. @frederikaalund, what are your thoughts on this? |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm using aiomqtt in a FastAPI application, and it has been working fine until got an unexpected disconnection. I'm not sure how to best deal with this. Part of the problem is that I find it hard to recreate a disconnection for testing purposes.
I was thinking of something like this:
My questions are:
client.publish()
or is there a nicer way to do it once (I guess I could make a newpublish_with_reconnect()
function.)Beta Was this translation helpful? Give feedback.
All reactions