-
Notifications
You must be signed in to change notification settings - Fork 168
Subscription's errors not handled as expected on session end #293
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
Comments
Thank you for your report. Mqtt3RxClient client = Mqtt3Client.builder()
.identifier("id")
.serverHost("broker.hivemq.com")
.automaticReconnectWithDefaultConfig()
.addConnectedListener(context -> System.out.println("connected"))
.addDisconnectedListener(context -> System.out.println("disconnected"))
.buildRx();
Disposable disposable = client.connectWith().keepAlive(5).applyConnect()
.doOnSuccess(connAck -> System.out.println("Successfully connected to hivemq: " + connAck.getReturnCode()))
.ignoreElement()
.andThen(client.subscribeStreamWith()
.topicFilter("a/b/c").qos(MqttQos.AT_LEAST_ONCE)
.applySubscribe())
.subscribe(
p -> System.out.println("Received message"),
x -> System.err.println("Uh Oh we shouldnt get here" + x)); Results:
As the session expired, it seems that you are using cleanSession=true. Could you share the contents of |
quick suggestion: if you add a retry for the subscribe the client will try to re-subscribe Disposable disposable = client.connectWith().keepAlive(5).applyConnect()
.doOnSuccess(connAck -> System.out.println("Successfully connected to hivemq: " + connAck.getReturnCode()))
.ignoreElement()
.andThen(client.subscribeStreamWith()
.topicFilter("a/b/c").qos(MqttQos.AT_LEAST_ONCE)
.applySubscribe()
.retry())
.subscribe(
p -> System.out.println("Received message"),
x -> System.err.println("Uh Oh we shouldnt get here" + x)); |
Another question: Is it expected that the client re-subscribes automatically when the client reconnects automatically? If so, we could add a feature request for that. |
Thanks for the quick reply. Our connect looks like :
I've tried your suggestions above and am still not able to get the client to reconnect. And yes it would be great if the client is able to resubscibe when the client reconnects |
How do you observe that the client does not reconnect? Did you add a DisconnectedListener and a ConnectedListener? |
The initial connect is successful then we manually disconnect the client via the HiveMQ Dashboard. Here is the output when we disconnected the client
|
We were able to dig around the code a bit and found that the clients old MqttClientConfig was being used and not it's MqttConnect. So we moved our simpleAuth from the MqttConnect object to the MqttClient object. With this move we were able to successfully reconnect. |
Thank you for identifying another bug. This should be a |
Thanks for the help @SgtSilvio! Closing the issue now. |
Expected behavior
Given a Mqtt3RxClient connected with two or more subscriptions
When MQTT session ends unexpectedly
Then the subscriptions onError method should be called
and client should reconnect
Actual behavior
The RxJavaPlugins.onError() is called
and client does not reconnect
To Reproduce
Steps
Connect client to broker with two or more subscriptions
End client's session with broker
Reproducer code
Details
The text was updated successfully, but these errors were encountered: