Skip to content

Commit

Permalink
Decrease default MQTT Maximum Packet Size
Browse files Browse the repository at this point in the history
Given that the default max_message_size got decreased from 128 MiB to 16
MiB in RabbitMQ 4.0 in #11455,
it makes sense to also decrease the default MQTT Maximum Packet Size from 256 MiB to 16 MiB.
Since this change was missed in RabbitMQ 4.0, it is scheduled for RabbitMQ 4.1.
  • Loading branch information
ansd committed Sep 20, 2024
1 parent 77bf0ad commit bddc546
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion deps/rabbitmq_mqtt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ APP_ENV = """[
{mailbox_soft_limit, 200},
{max_packet_size_unauthenticated, 65536},
%% 256 MB is upper limit defined by MQTT spec
{max_packet_size_authenticated, 268435455},
%% We set 16 MB as defined in deps/rabbit/Makefile max_message_size
{max_packet_size_authenticated, 16777216},
{topic_alias_maximum, 16}
]
"""
Expand Down
3 changes: 2 additions & 1 deletion deps/rabbitmq_mqtt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ define PROJECT_ENV
{mailbox_soft_limit, 200},
{max_packet_size_unauthenticated, 65536},
%% 256 MB is upper limit defined by MQTT spec
{max_packet_size_authenticated, 268435455},
%% We set 16 MB as defined in deps/rabbit/Makefile max_message_size
{max_packet_size_authenticated, 16777216},
{topic_alias_maximum, 16}
]
endef
Expand Down
2 changes: 2 additions & 0 deletions deps/rabbitmq_mqtt/src/rabbit_mqtt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ persist_static_configuration() ->

{ok, MaxSizeAuth} = application:get_env(?APP_NAME, max_packet_size_authenticated),
assert_valid_max_packet_size(MaxSizeAuth),
{ok, MaxMsgSize} = application:get_env(rabbit, max_message_size),
?assert(MaxSizeAuth =< MaxMsgSize),
ok = persistent_term:put(?PERSISTENT_TERM_MAX_PACKET_SIZE_AUTHENTICATED, MaxSizeAuth).

assert_valid_max_packet_size(Val) ->
Expand Down
5 changes: 5 additions & 0 deletions release-notes/4.1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## RabbitMQ 4.1.0

## Potential incompatibilities

* The default MQTT [Maximum Packet Size](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901086) changed from 256 MiB to 16 MiB. This default can be overriden by [configuring](https://www.rabbitmq.com/docs/configure#config-file) `mqtt.max_packet_size_authenticated`. Note that this value must not be greater than `max_message_size` (which also defaults to 16 MiB).

0 comments on commit bddc546

Please sign in to comment.