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

MqttServer stops responding #1542

Closed
FYN-Michiel opened this issue Oct 14, 2022 · 8 comments · Fixed by #1549
Closed

MqttServer stops responding #1542

FYN-Michiel opened this issue Oct 14, 2022 · 8 comments · Fixed by #1549
Labels
bug Something isn't working

Comments

@FYN-Michiel
Copy link

FYN-Michiel commented Oct 14, 2022

Using version 4.1.1.318 the MqttServer sometimes stops responding/processing to new messages after a while.
When reverting to 4.1.0.247 everything returns to normal (no other code changes).

We use an MQTTnet MqttServer on localhost to communicate between processes, this runs on about 75+ machines.
It doesn't happen on every machine (about 1:10) and doesn't happen very often (about every other day).

Working on a way to reproduce this (or provide more information), doesn't want to occur on our debug machines.

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.

    public void Start(Int32 port, String username, String password)
    {
        _username = username;
        _password = password;
        MqttServerOptionsBuilder optionsBuilder = new MqttServerOptionsBuilder()
            .WithDefaultEndpoint()
            .WithDefaultEndpointPort(port);
        
        MqttServer = new MqttFactory().CreateMqttServer(optionsBuilder.Build());
        MqttServer.ValidatingConnectionAsync += MqttServerOnValidatingConnectionAsync;
        MqttServer.StartAsync();
    }
    private Task MqttServerOnValidatingConnectionAsync(ValidatingConnectionEventArgs arg)
    {
        if (!String.Equals(arg.UserName, _username, StringComparison.Ordinal) || !String.Equals(arg.Password, _password, StringComparison.Ordinal))
        {
            arg.ReasonCode = MqttConnectReasonCode.BadUserNameOrPassword;
            return Task.CompletedTask;
        }

        arg.ReasonCode = MqttConnectReasonCode.Success;
        return Task.CompletedTask;
    }

    public MqttServer MqttServer;
@FYN-Michiel FYN-Michiel added the bug Something isn't working label Oct 14, 2022
@chkr1011
Copy link
Collaborator

I created a branch for this ticket. It is possible that you test a build from the myget feed? I will then revert the changes one by one from the latest version so find the root cause. If you can also build the repo directly for testing, please let me know.

@FYN-Michiel
Copy link
Author

Can absolutely test dev builds (as long as they are signed), just let me know which one to pull (and allow for a few days of testing).

@chkr1011
Copy link
Collaborator

OK will let you know as soon I have a build available on the myget feed.

And you don't attach any other event handlers?

@chkr1011
Copy link
Collaborator

@FYN-Michiel Please try build 4.1.1.336 from the myget feed and let me know if it works better.

@FYN-Michiel
Copy link
Author

FYN-Michiel commented Oct 18, 2022

And you don't attach any other event handlers?

There are no other handlers attached, all logic is done through the clients.

@FYN-Michiel Please try build 4.1.1.336 from the myget feed and let me know if it works better.

Pulled version 4.1.1.339 (or does it need to be 336 exactly?), will be released to the machines tomorrow, will report back later.
Thanks for the work so far.

@chkr1011
Copy link
Collaborator

@FYN-Michiel Please use the exact version I posted. Other versions are from other feature branches so they may do not contain the actual fix. In the meantime, I figured out some issues in the AsyncLock replacement and fixed them. Now please try version x.x.x.340.

@FYN-Michiel
Copy link
Author

Pushing x.x.x.340 now, will report back after a few days.

@chkr1011 chkr1011 linked a pull request Oct 23, 2022 that will close this issue
@FYN-Michiel
Copy link
Author

Thanks, no more issues have been found, many thanks for the support :)

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

Successfully merging a pull request may close this issue.

2 participants