Skip to content

Commit

Permalink
disconnect old client completely
Browse files Browse the repository at this point in the history
  • Loading branch information
kickster97 committed Jan 7, 2025
1 parent aef039d commit e47f78c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lavinmq/mqtt/broker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module LavinMQ
def connect_client(socket, connection_info, user, packet)
if prev_client = @clients[packet.client_id]?
Log.trace { "Found previous client connected with client_id: #{packet.client_id}, closing" }
prev_client.close
disconnect_client(prev_client)
end
client = MQTT::Client.new(socket, connection_info, user, @vhost, self, packet.client_id, packet.clean_session?, packet.will)
if session = sessions[client.client_id]?
Expand All @@ -62,6 +62,7 @@ module LavinMQ
sessions.delete(client_id) if session.clean_session?
end
@clients.delete client_id
client.close
vhost.rm_connection(client)
end

Expand Down

0 comments on commit e47f78c

Please sign in to comment.