Closed leomuko closed 1 week ago
Hi @leomuko,
If you have the MQTT Disconnect reason code, the definitions are here.
If you are using the HiveMQ broker, you also have the option of running a Trace Recording to see the exact behavior and cause.
Questions:
Timber.tag(TAG).e(it.cause)
Timber.tag(TAG).e(it.source.name)
Timber.tag(TAG).d(it.toString())
Hello @pglombardo,
I am using the Cloudflare Pub/Sub service (https://developers.cloudflare.com/pub-sub/).
The output from the code is as follows:
Timber.tag(TAG).e(it.cause) outputs:
com.hivemq.client.mqtt.mqtt5.exceptions.Mqtt5DisconnectException: Server sent DISCONNECT.
Timber.tag(TAG).e(it.source.name) outputs: SERVER Let me know if you need any additional details!
Ok thanks. You can use this code to get the Disconnect packet details. It should output the DISCONNECT packet reason code.
Alternatively, if Cloudflare doesn't offer any type of logging visibility, another option may be to use Wireshark to monitor the MQTT traffic - watch for the DISCONNECT packets and then find the reason codes there.
Thanks, this has been helpful
I am experiencing frequent disconnections from the MQTT broker, where the server disconnects the client after a few seconds of being connected. I am trying to debug this issue, but I'm only able to see limited information in the disconnection event.
However, besides a cause and source name, no extra reason is provided as to why the server has been disconnected. I am able to This provides a cause and source name, but no additional reason or detailed error code is returned to explain why the server disconnected the client.
My Setup:
I can publish messages and intermittently receive messages when connected, but the server repeatedly disconnects the client without a clear reason. Without specific reason codes or error messages, it’s challenging to diagnose and resolve the disconnections.
Initialization Code:
Connection Code:
Subscription Code:
Publish Message Code:
Request for Guidance: Could you please guide me on how to obtain the full errors or reason codes provided by the broker when the server disconnects the client? I am not expecting detailed Hive MQTT logs but am specifically looking to capture and understand the error or reason codes from the broker itself. Any advice or additional debugging steps would be greatly appreciated.