-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Disconnect an mqtt client from an isolate #4
Comments
Hey @Fianax, are you using the latest version? The Mqtt is being instantiated and used inside the isolate handler or on the main thread? |
@Fianax I'm currently using the MQTT client inside the worker without any problem, but maybe the isolate is not being killed because it is still processing a message. I added an immediate option to the dispose method that will kill the isolate without necessarily awaiting the current operation finish. Can you try using the |
The mqtt client created it inside the isolate because as the isolates do not share memory with the main thread and I cannot pass the instance that it had created in another screen. That is why I create it within the isolate itself and I pass it the ip of the server and the port. |
Sorry but nothing has changed. The problem is that even if the worker dies (because I check that he is dead), the mqtt client is still connected to the server (I see that he is exactly). But when I close the application or exit it and go back in, then it is already disconnected. The mqtt client works perfectly in the isolate but it is rare that it does not disconnect from the server when I kill the worker but when changing the screen it does not disconnect either. |
Can you create an example project reproducing this bug? I would like to investigate more @Fianax |
Of course |
I've been doing more testing and I think it fails when I get a large amount of information per second. Stop entering the client.updates method? .Listen ((List <MqttReceivedMessage > c) async {} but it does not disconnect. But when information stops arriving, if I kill the worker, then the mqtt client does disconnect. PS: I am doing the example and I will also try to put it without isolate to see if it also fails when the amount of data is very large. |
Hey @Fianax, did you try using the main thread? The behavior that you are facing seems to be related to a huge number of events being processed. Can you try to reproduce on the main thread and see if closing the client, and canceling the StreamSubscription, the events stop being processed at the same time? |
Yes, when I do it in the main thread the data flow stops. But the interface crashes due to the large amount of data, that's why I do it in an isolate. |
I have been doing more tests and, after a while connected, data stops arriving. client.update.listen stops running but the client is still connected. The data keeps coming in but it is no longer launched in client.update.listen and therefore, I no longer have any more data to update. And I don't know if it's the isolate. If I do everything in the main, nothing bad happens but the screen crashes. |
In the end, using some mqtt-client properties, I get that when it stops receiving data, only the client disconnects and from the 'mainMessageHandle' I send a message to the worker so that the client connects again. I'm sorry to have bothered you. |
Hi, I have created a client on an isolate. When I do worker.dispose (), the client keeps receiving data from the mqtt server until it disconnects (when receiving a lot of data, even though I kill the worker, I keep receiving the data that has been queued, so when I kill the worker I keep receiving data).
But I would like to be able to disconnect him, without waiting for him to disconnect. Can I send a message to the worker to disconnect it? How does the worker work when I send it several messages, I mean, does the isolate method run again?
Sorry for the inconvenience.
The text was updated successfully, but these errors were encountered: