-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Unexpected async result" and need to explicitly re-subscribe to topics. #134
Comments
How are you subscribing to topics in the first place? If you are passing If on the other hand you are attempting to call the See #130, in short, I couldn't get dynamic subscriptions working reliably. In the end I gave up. I think that the mqtt-5 rewrite is suppose to resolve issues such as this through a better design, but I suspect nobody has time to look at it this. I am not even sure where it got to. See the mqtt-5 branch though. I think the idea in the current code is that you are expected to resubscribe after the connection is re-established. But not 100% sure of this. |
Hi @brianmay thanks for replying.
Unfortunately, my subscriptions are not dynamic. They are standard one-time subscriptions: opts = [
client_id: client_id,
user_name: username,
password: raw_token,
server: server,
handler: {FarmbotExt.MQTT, [client_id: client_id, username: username]},
backoff: [min_interval: 8_000, max_interval: 120_000],
subscriptions: [
{"bot/#{username}/from_clients", 0},
{"bot/#{username}/ping/#", 0},
{"bot/#{username}/sync/#", 0},
{"bot/#{username}/terminal_input", 0}
]
]
{Tortoise.Connection, opts} It sounds like I will need to leave the re-subscription code in for now. |
Hmmm. It is very possible I just assumed that resubscriptions worked, without actually testing it. Thanks for you code excerpt, I probably should add it to my code. Based on my experience in #130 this makes me a bit nervous also. But maybe subscribing to topics all at once - like you appear to do - instead of one at a time - like I was - might help here. |
I can confirm seeing that |
The more I think about it, the more I seem to recall that the options passed to the init function really are suppose to be persistent across connections. So either my memory is faulty. Or there is a bug in the code somewhere that is preventing this from working correctly. |
I had to revert the resubscription change, it killed everything. Looks like #130.
|
Automatic re-subscribing seems to "work for me"(TM). No idea why it didn't work for you:
|
@brianmay Not sure what happened. I changed a few settings and everything appears to be working now, so I will assume this issue was a problem with my local configuration rather than a problem with the library. Closing. |
Greetings,
We are transitioning our codebase to use Tortoise. Today I noticed that if I intentionally take my broker offline, the connection will re-establish itself with the broker automatically, but it will not re-subscribe to the previous topics.
My question is: is this expected behavior, or am I using the library wrong?
Qucik Fix (Maybe?)
I was able to fix the problem with the following snippet:
I am not seeing or reading about other projects needing to do this, so I feel like maybe I made a mistake somewhere or am misunderstanding the documentation.
A Warning
Additionally, I get the following log (source code here):
This only happens after re-subscribing.
Example Code
Since the project is also open-source, you can view the real-world offending code here and here, but it would probably be better if I created an isolated repo to demonstrate the problem. I am happy to do so if that helps- please let me know.
Thanks for all the work you put into this project! Despite this one hiccup, we've had a great experience so far.
The text was updated successfully, but these errors were encountered: