From 1d7d4fe7064a9b63521f85b2fe1ad28ec14f15be Mon Sep 17 00:00:00 2001 From: Andrey Demenev Date: Sat, 22 Nov 2025 23:39:18 +0400 Subject: [PATCH] clean up state after disconnect after disconnect, subscriptions and pending messages are lost, so there is no point to keep them. When they are kept, after reconnect it is not possible to resubscribe --- src/mqtt_client.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt_client.erl b/src/mqtt_client.erl index 7d1bf75..738a0df 100644 --- a/src/mqtt_client.erl +++ b/src/mqtt_client.erl @@ -613,7 +613,7 @@ handle_info({mqtt, disconnected}, State) -> Fun when is_function(Fun) -> spawn(fun() -> Fun(Self) end) end, - {noreply, State}; + {noreply, State#state{pending_publishes = #{}, pending_subscriptions = #{}, pending_unsubscriptions = #{}, subscriber_map = #{}}}; handle_info({mqtt, error, Error}, State) -> ?TRACE("handle_info({mqtt, disconnected}~n", []), Config = State#state.config,