MQTT QoS 2 does NOT resend messages after some days

277 Views Asked by At

we are using mqtt broker version 2.0.11 from eclipse running on Ubuntu 22.04.1.

This is the configuration file (server)

persistence true
persistence_location xxxxxxxxxx
per_listener_settings true
log_timestamp_format [%Y-%m-%d %H:%M:%S]
max_inflight_messages 1000
#
#       Port 1883 (NO TLS)
#
listener 1883
allow_anonymous true
allow_zero_length_clientid false
#
#       Port 8883 (TLS)
#
listener 8883
allow_anonymous false
allow_zero_length_clientid false
cafile xxxxxxx
certfile xxxxxxx
keyfile xxxxxxx
dhparamfile xxxxxxx
password_file xxxxxxx
acl_file xxxxxxx

We have a client that has been disconnected from the broker for about 6 days.

When the client restarted we had this message ClientState: xxxxxxxxxxx: Timed out as no activity, keepAlive=20,000,000,000 lastOutboundActivity=5,084,923,567,979 ....

This is the client configuration parameters (relevants)

QoS=2
AutoReconnect=true
CleanSession=false
connectionTimeout=60
keepAliveInterval=20
maxInflight=1000

No old messages have been sent...

Is there any retention period of old messages?

Thanks in advance for your support.

1

There are 1 best solutions below

0
hardillb On

The is no default retention period when using mosquitto as your broker. The is an option to set one, but as noted in the man page, if this value is not set then sessions (and the associated queued messages) will be kept for ever.

persistent_client_expiration duration

This option allows the session of persistent clients (those with clean session set to false) that are not currently connected to be removed if they do not reconnect within a certain time frame. This is a non-standard option in MQTT v3.1. MQTT v3.1.1 and v5.0 allow brokers to remove client sessions.

Badly designed clients may set clean session to false whilst using a randomly generated client id. This leads to persistent clients that connect once and never reconnect. This option allows these clients to be removed. This option allows persistent clients (those with clean session set to false) to be removed if they do not reconnect within a certain time frame.

The expiration period should be an integer followed by one of h d w m y for hour, day, week, month and year respectively. For example:

 - persistent_client_expiration 2m

 - persistent_client_expiration 14d

 - persistent_client_expiration 1y

As this is a non-standard option, the default if not set is to never expire persistent clients.

This strongly implies some other problem, hence the checking that client ids do truly match across reconnects.