Allow MQTT v5.0 outgoing bridges to fall back to MQTT v3.1.1

This applies if connecting to a v3.x only broker.
pull/1658/head
Roger A. Light 6 years ago
parent f0deb9a5a1
commit c72dd39f92

@ -8,6 +8,8 @@ Broker:
bridging to e.g. Amazon or Google.
- Add support for MQTT v5 bridges to handle the "retain-available" property
being false.
- Allow MQTT v5.0 outgoing bridges to fall back to MQTT v3.1.1 if connecting
to a v3.x only broker.
Client library:
- Client no longer generates random client ids for v3.1.1 clients, these are

@ -41,6 +41,18 @@ int handle__connack(struct mosquitto_db *db, struct mosquitto *context)
if(packet__read_byte(&context->in_packet, &reason_code)) return 1;
if(context->protocol == mosq_p_mqtt5){
if(context->in_packet.remaining_length == 2 && reason_code == CONNACK_REFUSED_PROTOCOL_VERSION){
/* We have connected to a MQTT v3.x broker that doesn't support MQTT v5.0
* It has correctly replied with a CONNACK code of a bad protocol version.
*/
log__printf(NULL, MOSQ_LOG_NOTICE,
"Warning: Remote bridge %s does not support MQTT v5.0, reconnecting using MQTT v3.1.1.",
context->bridge->name);
context->protocol = mosq_p_mqtt311;
context->bridge->protocol_version = mosq_p_mqtt311;
return MOSQ_ERR_PROTOCOL;
}
rc = property__read_all(CMD_CONNACK, &context->in_packet, &properties);
if(rc) return rc;
mosquitto_property_free_all(&properties);

Loading…
Cancel
Save