empicano/aiomqtt

How can I set the value of session_expiry_interval for a client?

YraganTron opened this issue · 1 comments

How can I set the value of session_expiry_interval for a client?

Hi Arseny, and thank you for opening this issue. :)

You can use the properties argument for Client.__init__ like so:

from aiomqtt import Client
from paho.mqtt.properties import Properties
from paho.mqtt.packettypes import PacketTypes

properties = Properties(PacketTypes.CONNECT)
properties.SessionExpiryInterval = 1234
client = aiomqtt.Client(..., properties=properties)

Note that I did not run the code above. There may be typos or the like.

The current API for MQTTv5 properties is admittedly pretty awkward to use. It's a great place to make a PR and improve this situation. 👍

I hope this helps!