fix(conninfo): Ensure receive_maximum do not exceed limit
This commit is contained in:
parent
e862ff6b20
commit
b10a60cddb
|
@ -182,6 +182,8 @@
|
|||
-define(MAX_PACKET_SIZE, 16#FFFFFFF).
|
||||
-define(MAX_TOPIC_AlIAS, 16#FFFF).
|
||||
|
||||
-define(MAX_INFLIGHT_HARD_LIMIT, 32767).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% MQTT Frame Mask
|
||||
%%--------------------------------------------------------------------
|
||||
|
|
|
@ -936,8 +936,8 @@ end}.
|
|||
%% 0 is equivalent to maximum allowed
|
||||
{mapping, "zone.$name.max_inflight", "emqx.zones", [
|
||||
{default, 0},
|
||||
{datatype, integer}
|
||||
{validators, ["range:1-32767"]},
|
||||
{datatype, integer},
|
||||
{validators, ["range:1-32767"]}
|
||||
]}.
|
||||
|
||||
%% @doc Retry interval for redelivering QoS1/2 messages.
|
||||
|
|
|
@ -1142,9 +1142,13 @@ expiry_interval(Zone, #mqtt_packet_connect{clean_start = false}) ->
|
|||
expiry_interval(_Zone, #mqtt_packet_connect{clean_start = true}) ->
|
||||
0.
|
||||
|
||||
-compile({inline, [receive_maximum/2]}).
|
||||
receive_maximum(Zone, ConnProps) ->
|
||||
emqx_mqtt_props:get('Receive-Maximum', ConnProps, emqx_zone:max_inflight(Zone)).
|
||||
MaxInflightConfig = case emqx_zone:max_inflight(Zone) of
|
||||
0 -> ?MAX_INFLIGHT_HARD_LIMIT;
|
||||
N -> N
|
||||
end,
|
||||
MaxByClient = emqx_mqtt_props:get('Receive-Maximum', ConnProps, MaxInflightConfig),
|
||||
erlang:min(MaxByClient, MaxInflightConfig).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% Run Connect Hooks
|
||||
|
|
|
@ -662,7 +662,7 @@ inc_expired_cnt(message, N) ->
|
|||
|
||||
-compile({inline, [next_pkt_id/1]}).
|
||||
|
||||
next_pkt_id(Session = #session{next_pkt_id = 16#FFFF}) ->
|
||||
next_pkt_id(Session = #session{next_pkt_id = ?MAX_PACKET_ID}) ->
|
||||
Session#session{next_pkt_id = 1};
|
||||
|
||||
next_pkt_id(Session = #session{next_pkt_id = Id}) ->
|
||||
|
|
Loading…
Reference in New Issue