Skip to content

MqttClient subscribe: MqttConnectionBase::_onDone - calling disconnected callback #640

@Rityra

Description

@Rityra

This seems to be related to this other issue.

I am implementing this in a mobile app.

Everything seems to be working alright, up until this:

client
        ..publishMessage(topic, MqttQos.atLeastOnce, builder.payload!) // SUCCESS
        ..subscribe(topic, MqttQos.atLeastOnce); // SILENT FAILURE

The related logs are:

I/flutter ( 5456): 1-2026-01-26 10:51:59.643427 -- PublishingManager::publish - entered with topic $aws/things/smartThing/shadow/update/documents
I/flutter ( 5456): 1-2026-01-26 10:51:59.652441 -- MqttConnectionHandlerBase::sendMessage
I/flutter ( 5456): 1-2026-01-26 10:51:59.657965 -- MqttConnectionHandlerBase::sendMessage = message is MQTTMessage of type MqttMessageType.publish
I/flutter ( 5456): Header: MessageType = MqttMessageType.publish, Duplicate = false, Retain = false, Qos = MqttQos.atLeastOnce, Size = 61
I/flutter ( 5456): Publish Variable Header: TopicName={$aws/things/smartThing/shadow/update/documents}, MessageIdentifier={1}, VH Length={0}
I/flutter ( 5456): Payload: {11 bytes={<72><101><108><108><111><32><87><111><114><108><100>
I/flutter ( 5456): 1-2026-01-26 10:52:15.700489 -- MqttConnectionHandlerBase::sendMessage
I/flutter ( 5456): 1-2026-01-26 10:52:15.704027 -- MqttConnectionHandlerBase::sendMessage = message is MQTTMessage of type MqttMessageType.subscribe
I/flutter ( 5456): Header: MessageType = MqttMessageType.subscribe, Duplicate = false, Retain = false, Qos = MqttQos.atLeastOnce, Size = 51
I/flutter ( 5456): Subscribe Variable Header: MessageIdentifier={2}
I/flutter ( 5456): Payload: Subscription [{1}]
I/flutter ( 5456): {{ Topic={$aws/things/smartThing/shadow/update/documents}, Qos={MqttQos.atLeastOnce} }}
I/flutter ( 5456): 
I/flutter ( 5456): 1-2026-01-26 10:52:15.712493 -- MqttConnectionKeepAlive::pingRequired
I/flutter ( 5456): 1-2026-01-26 10:52:15.713637 -- MqttConnectionKeepAlive::pingRequired - sending ping request
I/flutter ( 5456): 1-2026-01-26 10:52:15.714032 -- MqttConnectionHandlerBase::sendMessage
I/flutter ( 5456): 1-2026-01-26 10:52:15.714863 -- MqttConnectionHandlerBase::sendMessage = message is MQTTMessage of type MqttMessageType.pingRequest
I/flutter ( 5456): Header: MessageType = MqttMessageType.pingRequest, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter ( 5456): 1-2026-01-26 10:52:15.716181 -- MqttConnectionKeepAlive::pingRequired - restarting ping timer
I/flutter ( 5456): 1-2026-01-26 10:52:15.767738 -- MqttConnectionBase::_onDone - calling disconnected callback
I/flutter ( 5456): 1-2026-01-26 10:52:15.772032 -- MqttConnectionKeepAlive::stop - stopping keep alive

I have tried all possible MqttQos qosLevels, tried different topics, but to no avail.
In AWS I see that the disconnection activity is as follows:

{
  "clientId": "smartThing",
  "timestamp": 1769420715167,
  "eventType": "disconnected",
  "clientInitiatedDisconnect": false,
  "sessionIdentifier": "96d50310-a796-4b2d-9595-4f6244fff843",
  "principalIdentifier": "c145d9c1c7e799778bebbada415dadbd22f16a36b66c333e5a9baa186d0f4414",
  "disconnectReason": "CLIENT_ERROR",
  "versionNumber": 34
}

... but the subscribe method doesn't seem to be throwing any errors.
Thank you for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions