Commit 2283e2c14916c34e9bfea896066dffa62ebe90b1

Authored by Wiebe Cazemier
1 parent 72858041

Allow MQTT5 non-clean start empty client ID

When you have the server generate a client ID: "It MUST then process the
CONNECT packet as if the Client had provided that unique ClientID, and
MUST return the Assigned Client Identifier in the CONNACK packet".

So, this means allowing an empty client ID, even for non-clean start,
should be allowed.
Showing 1 changed file with 2 additions and 2 deletions
mqttpacket.cpp
... ... @@ -724,9 +724,9 @@ void MqttPacket::handleConnect()
724 724 logger->logf(LOG_ERR, "ClientID '%s' has + or # in the id and 'allow_unsafe_clientid_chars' is false.", connectData.client_id.c_str());
725 725 validClientId = false;
726 726 }
727   - else if (!connectData.clean_start && connectData.client_id.empty())
  727 + else if (protocolVersion < ProtocolVersion::Mqtt5 && !connectData.clean_start && connectData.client_id.empty())
728 728 {
729   - logger->logf(LOG_ERR, "ClientID empty and clean start 0, which is incompatible");
  729 + logger->logf(LOG_ERR, "ClientID empty and clean start 0, which is incompatible below MQTTv5.");
730 730 validClientId = false;
731 731 }
732 732 else if (protocolVersion < ProtocolVersion::Mqtt311 && connectData.client_id.empty())
... ...