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

Mqtt client does NOT auto reconnect when receiving exception "Timed out as no write activity" #1065

Open
pentolone opened this issue Dec 19, 2024 · 0 comments

Comments

@pentolone
Copy link

Version: spring integration mqtt 6.2.1
Java: 11/17/21
Configuration:
autoReconnect: true
cleanSession: true

Expected behaviour:

after receiving exception "Timed out as no write activity, keepAlive=60.000.000.000 lastOutboundActivity=6.114.183.067.622.000 lastInboundActivity=6.114.206.492.058.900 time=6.114.423.973.125.000 lastPing=6.114.183.067.640.300"
the client should reconnect to the broker

Actual behaviour:
the client never reconnects

How to reproduce:

  1. Write simple mqtt client
  2. Start in debug mode
  3. Set a break point when receiving message
  4. Publish a message via mqtt explorer or whatever client you want
  5. Stop in break point for, at least, 4 minutes
  6. Proceed in the application

We identified the potential issue in the callback class.

public class CommsCallback implements Runnable

The problem looks like is in this method.

`public void start(String threadName, ExecutorService executorService) {
this.threadName = threadName;
synchronized(this.lifecycle) {
if (this.current_state == CommsCallback.State.STOPPED) {
this.messageQueue.clear();
this.completeQueue.clear();
this.target_state = CommsCallback.State.RUNNING;
if (executorService == null) {
(new Thread(this)).start();
} else {
this.callbackFuture = executorService.submit(this);
}
}
}

    while(!this.isRunning()) {
        try {
            Thread.sleep(100L);
        } catch (Exception var4) {
        }
    }

}`

When receiving exception the variable current_state remains in CommsCallback.State.RUNNING.

While the variable target_state is in status CommsCallback.State.STOPPED

But, if I stop and restart the mqtt broker, the behaviour is correct (the client reconnects).

I try to open the issue even if I know that the last update on this project was long time ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant