I’m investigating LiveView JS client errors when the Socket/LiveSocket throws failed with reason: {"reason":"unmatched topic"}
.
I modified Phoenix 1.8.1 to emit telemetry events when the “unmatched topic” condition happens server side and collected some of those events (including socket
and reply
) with production traffic for debugging.
It turns out a batch of such errors all were related to the :longpoll
transport and I’m trying to understand what the underlying cause might be, and whether I can safely ignore those errors assuming the channel connection will be re-established anyway later.
I have a proxy (Cloudflare) between users and the server.
This is one of the events, PII scrubbed:
%{
name: [:phoenix, :socket_unmatched_topic],
metadata: %{
reply: %Phoenix.Socket.Reply{
topic: "lv:phx-GGJYSitVRluvhDWD",
status: :error,
payload: %{reason: "unmatched topic"},
ref: "92",
join_ref: nil
},
socket: %Phoenix.Socket{
assigns: %{},
channel: nil,
channel_pid: nil,
endpoint: MyAppWeb.Endpoint,
handler: Phoenix.LiveView.Socket,
id: nil,
joined: false,
join_ref: nil,
private: %{
connect_info: %{
x_headers: [
# ...
]
}
},
pubsub_server: MyApp.PubSub,
ref: nil,
serializer: Phoenix.Socket.V2.JSONSerializer,
topic: nil,
transport: :longpoll,
transport_pid: #PID<0.33718.0>
}
},
measurements: %{system_time: 1757064975931223300}
}
Has anybody explored this area before and could help shed some light?
What additional data could I gather?
My current thought is that the client either misses a ping/heartbeat or the proxy terminates a connection earlier, causing a server process backing the channel connection to go away. Probably the client reconnects spawning a new process / "lv:..."
topic and the user doesn’t even notice
It would help me to reproduce this locally, so any tips / shortcuts are welcome