feat: implement websocket URL creation and enhance websocket connection logging

This commit is contained in:
mlogclub
2026-04-14 19:59:49 +08:00
parent 2222256f5a
commit 0f3d110018
5 changed files with 27 additions and 8 deletions
+15 -1
View File
@@ -77,6 +77,9 @@ export function useAgentConversationRealtime() {
websocketRef.current = socket
socket.onopen = () => {
console.info("[agent-realtime] websocket connected", {
url: socket.url,
})
reconnectAttemptRef.current = 0
if (pingTimerRef.current) {
window.clearInterval(pingTimerRef.current)
@@ -180,7 +183,14 @@ export function useAgentConversationRealtime() {
}
}
socket.onclose = () => {
socket.onclose = (event) => {
console.log("[agent-realtime] websocket closed", {
url: socket.url,
readyState: socket.readyState,
code: event.code,
reason: event.reason,
wasClean: event.wasClean,
})
if (pingTimerRef.current) {
window.clearInterval(pingTimerRef.current)
pingTimerRef.current = null
@@ -193,6 +203,10 @@ export function useAgentConversationRealtime() {
}
socket.onerror = () => {
console.log("[agent-realtime] websocket error", {
url: socket.url,
readyState: socket.readyState,
})
scheduleReconnect()
}
}