Skip to content

Commit

Permalink
Fix max_keepalive option not being able to be set to 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Sep 9, 2021
1 parent 9afeeb1 commit d942ed7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.txt
@@ -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
===================

Expand Down
10 changes: 9 additions & 1 deletion man/mosquitto.conf.5.xml
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions mosquitto.conf
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/conf.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit d942ed7

Please sign in to comment.