Skip to content

MQTT5 persistent session examples #364

@golkedj

Description

@golkedj

I'm currently leveraging aiomqtt 2.3.2 in combination with AWS IoT MQTT and I'm trying to get persistent sessions on my clients working.

I have the following client initiation code:

        tls_params = aiomqtt.TLSParameters(
            ca_certs=self._config["ca_file"],
            certfile=self._config["cert_file"],
            keyfile=self._config["key_file"],
            tls_version=ssl.PROTOCOL_TLSv1_2,
        )

        _properties = paho.mqtt.properties.Properties(PacketTypes.CONNECT)
        _properties.SessionExpiryInterval = 60 * 60 * 24

        self._client = aiomqtt.Client(
            hostname=self._config["endpoint"],
            port=self._config["port"],
            tls_params=tls_params,
            identifier=self._config["client_id"],
            protocol=aiomqtt.ProtocolVersion.V5,
            keepalive=60,
            clean_start=False,
            properties=_properties,
        )

Per the MQTT documentation it would seem that I need to set clean_start to False and set a SessionExpiryInterval. I set the session expiry interval per #233 and #277, but it doesn't seem to pick up messages missed while offline with these settings. Is there any more information on how to do persistent sessions with this package with MQTT5?

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