Skip to content

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

Open
@pentolone

Description

@pentolone

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions