Skip to content

Commit

Permalink
Mqtt3
Browse files Browse the repository at this point in the history
  • Loading branch information
tgracchus committed Oct 27, 2023
1 parent 55e1715 commit 24983e4
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/main/java/com/hivemq/codec/decoder/MQTTMessageDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,13 @@ protected void decode(
//this is the message size HiveMQ allows for incoming messages
if (packetSize > mqttConfig.maxPacketSize()) {
//connack with PACKET_TOO_LARGE for Mqtt5
final ProtocolVersion protocolVersion = connectDecoder.decodeProtocolVersion(clientConnectionContext, buf);
if (protocolVersion == ProtocolVersion.MQTTv5) {
mqttConnacker.connackError(clientConnectionContext.getChannel(),
"A client (IP: {}) connect packet exceeded the maximum permissible size.",
"Sent CONNECT exceeded the maximum permissible size",
Mqtt5ConnAckReasonCode.PACKET_TOO_LARGE,
ReasonStrings.CONNACK_PACKET_TOO_LARGE);
} else { //force channel close for Mqtt3.1 and Mqtt3.1.1
mqttServerDisconnector.disconnect(clientConnectionContext.getChannel(),
"A client (IP: {}) sent a message, that was bigger than the maximum message size. Disconnecting client.",
"Sent a message that was bigger than the maximum size",
Mqtt5DisconnectReasonCode.PACKET_TOO_LARGE,
ReasonStrings.DISCONNECT_PACKET_TOO_LARGE_MESSAGE,
Mqtt5UserProperties.NO_USER_PROPERTIES,
false,
true);
}
connectDecoder.decodeProtocolVersion(clientConnectionContext, buf);
mqttConnacker.connackError(clientConnectionContext.getChannel(),
"A client (ID: {}, IP: {}) connect packet exceeded the maximum permissible size.",
"Sent CONNECT exceeded the maximum permissible size",
Mqtt5ConnAckReasonCode.PACKET_TOO_LARGE,
ReasonStrings.CONNACK_PACKET_TOO_LARGE);

return null;
}

Expand Down

0 comments on commit 24983e4

Please sign in to comment.