EMQX Dashboard问题

EMQX Dashboard的状态只能显示已连接的设备,如何设置才能显示下线的设备?

你好,以下线设备无法在 EMQX 中显示。

除非该客户端是以保留会话的模式链接上来的(即 clean_start 或 clean_session 参数设置为 false)。这种模式下,EMQX 会为此类客户端保留一个会话状态在服务器中,这样的话才能在这个页面看到

可以了,多谢!

还有一个问题,不知道有没有超出EMQX主题范围,使用 paho.mqtt.python库,重写的MQTT客户端,如何设置会话过期间隔,代码如下:
mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id=hostname, clean_session=False)
mqttc.username_pw_set(mqtt_username, mqtt_password)
mqttc.on_connect = on_connect
mqttc.on_message = on_message
mqttc.on_subscribe = on_subscribe
mqttc.on_publish = on_publish
#用于客户端掉线再次连接客户端
mqttc.on_disconnect = on_disconnect
mqttc.connect(host=mqtt_server, port=mqtt_port, keepalive=60)

MQTT V3.1.1 Version:
mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2,
client_id=hostname, protocol=mqtt.MQTTv311, clean_session=clean_session)
mqttc.connect(host=mqtt_server, port=mqtt_port, keepalive=60)

MQTT V5.0 Version:
mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2,
client_id=hostname, protocol=mqtt.MQTTv5)
properties = Properties(PacketTypes.CONNECT)
properties.SessionExpiryInterval = session_expiry_interval
mqttc.connect(host=mqtt_server, port=mqtt_port, keepalive=60,
clean_start=clean_start, properties=properties)