Closed bigcat26 closed 11 months ago
@bigcat26 How did you fix this? We are experiencing the same issue.
Would this do it or do you have to specifically interrupt a hanging socket?
.addDisconnectedListener(context -> {
context.getReconnector()
.reconnect(false);
})
More examples in this file.
@bigcat26 How did you fix this? We are experiencing the same issue.
I have applied the following changes in MqttDisconnectCompletable.java
:
protected void subscribeActual(final @NotNull CompletableObserver s) {
final MqttClientConnectionConfig connectionConfig = clientConfig.getRawConnectionConfig();
if (connectionConfig == null) {
// EmptyDisposable.error(MqttClientStateExceptions.notConnected(), s);
clientConfig.getRawState().set(MqttClientState.DISCONNECTED);
clientConfig.releaseEventLoop();
EmptyDisposable.complete(s);
return;
}
It seems works.
Checklist
issues
.discussions
.❓ Question
How to force cancel/interrupt a reconnecting state client?
📎 Additional context
When I try to disconnect a Mqtt3RxClient that is in the DISCONNECTED_RECONNECT state, it returns a throwable with the message ‘com.hivemq.client.mqtt.exceptions.MqttClientStateException: MQTT client is not connected.’ However, it may still successfully reconnect after a while, which is not what I want. I need to force an interruption of the reconnecting process immediately, such as by closing the underlying socket, but I did not find any API to access the underlying socket. Do you have any suggestions?