Skip to content
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 Connection not established after the Mqttnet Client is Disposed. in MQTTNet Version 4.3.3.952 #2072

Open
bharath1h opened this issue Aug 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@bharath1h
Copy link

Verification

Before opening a bug make sure that the following conditions are met.

  1. Performance issues are also appearing in RELEASE mode of your application.
  2. An increased memory consumption or high CPU load also happens when your application runs in RELEASE mode AND logging is DISABLED.
  3. Client issues with not received messages, connection drops etc. can be reproduced via another client application like "MQTTnetApp" (https://github.com/chkr1011/MQTTnetApp) or similar.
  4. The bug also appears in the VERY LATEST version of this library. There is no support for older version (due to limited resources) but pull requests for older versions are welcome.

Describe the bug

A clear and concise description of what the bug is.
When ever we are disposing the MQTT NET client upon reconnecting the MqttClientConnectedHandler is not getting hit.

public void Dispose()
{
try
{
Logger.Info("Dispose() | Cloud connector disposing ...");
DisconnectClient().Wait();
Logger.Error("Dispose() | Cloud connector disposed");
}
catch (Exception ex)
{
Logger.Fatal($"Dispose() | Failed to dispose cloud connector {ex}");
}
}
A job which runs every 2 minutes hits again we are getting the following exception

Exception: System.InvalidOperationException: It is not allowed to connect with a server after the connection is established.
at MQTTnet.Client.MqttClient.d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()

Which component is your bug related to?

  • Client

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of MQTTnet '4.3.3.952'.
  2. Run this code '....'.
  3. With these arguments '....'.
  4. See error.

Expected behavior

A clear and concise description of what you expected to happen.
upon disposing the client and retrying to connect the client should connect and the handler should hit.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context / logging

Add any other context about the problem here.
Include debugging or logging information here:

\\ Put your logging output here.

Code example

Please provide full code examples below where possible to make it easier for the developers to check your issues.

Ideally a Unit Test (which shows the error) is provided so that the behavior can be reproduced easily.

\\ Put your code here.
@bharath1h bharath1h added the bug Something isn't working label Aug 27, 2024
@bharath1h bharath1h changed the title MqttNet Connected Event handler is not getting called after Mqttnet Client is Disposed. MqttNet Connection not established after the Mqttnet Client is Disposed. in MQTTNet Version 4.3.3.952 Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant