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
MQTTnet.Exceptions.MqttCommunicationException: Cannot access a disposed object #733
Comments
For me, this seems quite similar to #728 (But it's not a duplicate). |
Finally, I got what was wrong. I was trying to access lo local broker (local ip) from the outside. The problem here was the exception messages didn't say anything about the connection was no able to be establish. Should the error message say something about that? |
If you ask me, yes. I'm not in the implementation details (yet), so @chkr1011 needs to answer this as well. |
I have a similar issue in my code. I am using ManagedClient with reconnect delay = 10 seconds. Sporadic in my logs i see exceptions like this when the client disconnects:
The client is able to reconnect to the server most of the times, but sometimes the client "dies" and does not run anymore. The last log message from MQTTClient in my log when this happens is this:
|
FWIW, I'm having the same exact issue as Erikkj. I have had several instances over the past few weeks where the client throws this exception and continues to fail to reconnect. Restarting the application clears it up. Sorry if this is a separate issue, I just ran across it while trying to Google my problem. |
I can confirm that this issue occurs occasionally on my test system, too. For the case it helps: I noticed that I never see a "OnDisconnected" event before the re-connecting fails. MQTTnet v3.0.8, .NET Core 3.0, Linux on ARM32. |
I have the same issue. |
I have a similar issue where I get a // Workaround for: workaround for https://github.com/dotnet/corefx/issues/24430
using (cancellationToken.Register(() => socket.Dispose()))
{
#if NET452 || NET461
await Task.Factory.FromAsync(socket.BeginConnect, socket.EndConnect, _options.Server, _options.GetPort(), null).ConfigureAwait(false);
#else
await socket.ConnectAsync(_options.Server, _options.GetPort()).ConfigureAwait(false);
#endif
} I would suggest catching the |
also getting this even with the new MQTTnet 3.0.9-rc1, but its usually in a combination with a timeout. It does reconnect then i get like 2-3 messages, the same happens again and so on until the client dies.
|
@Feyb @JanEggers confirmed. we're getting same object disposed exception with 3.0.9-rc1`. Thoughts? .NET Core 3.0, Windows 10 |
@andrei-m-code I dont know if @chkr1011 created a new version that contains the fixes I did last year? @chkr1011 can you please verify / do so? |
I'm expericing this same issue on v3.0.15 When I'm having it, it won't run until I reboot.
The translation for the socket error in english (from spanish is: 10013: An attempt was made to access a socket in a way forbidden by its access permissions. MqttServer calls both HandleServerStartedAsync and HandleServerStoppedAsync, which means I can't trust the started trigger to know if the Mqtt started successfully, as the stopped is called slightly after and later on it propagates to Krestel. Krestel fail is hard to track if you want to run it on behind while you do other things, as the run task will keep going unless start fails, sigterm or crtl+c. This means you have to do some wait/timeout to ensure startup was success (I know this is on me but maybe someone gives some insight for me), I have not been able to find any good candidate for somehwat StartupFullySuccess event. The ports I'm using currently are 9001 and 9002. For now when this issue shows up the only solution I find is to reboot. Is there any way that the port will get locked somehow even if I close everyhing? |
Please retest with version 4.0. You can also try to set the linger state and/or "ReuseAddress" in the server options |
I have an ASP Net Core 5.0 application hosted on the server. It was working well in production, but after some time, it crashed. When I tested the same code on my local, it was working fine, but any new build was getting the same issue. Can anyone help me here? do Unhandled exception. MQTTnet.Exceptions.MqttCommunicationException: Error while connecting with host 'Host address Name'. |
Hello,
I have a task with a parallel.ForEach ( I have also tried with a simple foreach)
And when I run the app I have the following error:
As a note, this happened to me in local, but I re-write the code from the beggining and it was fixed. Now I'm trying to deploy to AWS and the error happen again
The task ManageMQTTClient which produce the error:
The line 38 in the original code (here I have deleted the comments) is:
await mqttClientPublisher.ConnectAsync(optionsPublisher);
I'm using NuGet MQTTnet 3.0.5 and Net Core 2.1
Which project is your bug related to?
The text was updated successfully, but these errors were encountered: