From bd24dfcbed5c7a398ceb980b0b72d3d33df44423 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 11 Feb 2026 12:00:04 -0600 Subject: [PATCH] add diagnostic logging for agent result handling --- lib/towerops_web/channels/agent_channel.ex | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/towerops_web/channels/agent_channel.ex b/lib/towerops_web/channels/agent_channel.ex index 9543d6b8..1e399a41 100644 --- a/lib/towerops_web/channels/agent_channel.ex +++ b/lib/towerops_web/channels/agent_channel.ex @@ -334,6 +334,8 @@ defmodule ToweropsWeb.AgentChannel do @impl true @spec handle_in(String.t(), map(), socket()) :: {:noreply, socket()} def handle_in("result", %{"binary" => binary_b64}, socket) when is_binary(binary_b64) do + Logger.info("Received SNMP result from agent (binary size: #{byte_size(binary_b64)})") + with {:ok, binary} <- safe_base64_decode(binary_b64), {:ok, result} <- Validator.validate_snmp_result(binary) do maybe_debug_log(socket, "Received SNMP result from agent", @@ -547,6 +549,17 @@ defmodule ToweropsWeb.AgentChannel do end end + # Catch-all for unmatched events (diagnostic) + def handle_in(event, payload, socket) do + Logger.warning("Unhandled agent channel event", + event: event, + payload_keys: Map.keys(payload), + agent_token_id: socket.assigns.agent_token_id + ) + + {:noreply, socket} + end + # Private helpers @spec handle_validated_mikrotik_result(MikrotikResult.t(), socket()) :: {:noreply, socket()}