Fix max_keepalive option not being able to be set to 0.

This commit is contained in:
Roger A. Light 2021-09-09 12:19:13 +01:00
parent 9afeeb1a56
commit d942ed7eec
4 changed files with 24 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2.0.13 - 2021-xx-xx
===================
Broker:
- Fix `max_keepalive` option not being able to be set to 0.
2.0.12 - 2021-08-31
===================

View File

@ -599,7 +599,15 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
be sent a server keepalive telling them to use
max_keepalive. This only applies to MQTT v5 clients.
The maximum value allowable, and default value, is
65535. Do not set below 10 seconds.</para>
65535.</para>
<para>
Set to 0 to allow clients to set keepalive = 0, which
means no keepalive checks are made and the client will
never be disconnected by the broker if no messages are
received. You should be very sure this is the behaviour
that you want.
</para>
<para>
For MQTT v3.1.1 and v3.1 clients, there is no mechanism

View File

@ -79,8 +79,13 @@
# use the new keepalive value. The max_keepalive option allows you to specify
# that clients may only connect with keepalive less than or equal to this
# value, otherwise they will be sent a server keepalive telling them to use
# max_keepalive. This only applies to MQTT v5 clients. The maximum value
# allowable is 65535. Do not set below 10.
# max_keepalive. This only applies to MQTT v5 clients. The default, and maximum
# value allowable, is 65535.
#
# Set to 0 to allow clients to set keepalive = 0, which means no keepalive
# checks are made and the client will never be disconnected by the broker if no
# messages are received. You should be very sure this is the behaviour that you
# want.
#
# For MQTT v3.1.1 and v3.1 clients, there is no mechanism to tell the client
# what keepalive value they should use. If an MQTT v3.1.1 or v3.1 client

View File

@ -1671,7 +1671,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
config->max_inflight_messages = (uint16_t)tmp_int;
}else if(!strcmp(token, "max_keepalive")){
if(conf__parse_int(&token, "max_keepalive", &tmp_int, saveptr)) return MOSQ_ERR_INVAL;
if(tmp_int < 10 || tmp_int > UINT16_MAX){
if(tmp_int < 0 || tmp_int > UINT16_MAX){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid max_keepalive value (%d).", tmp_int);
return MOSQ_ERR_INVAL;
}