diff --git a/web/src/components/player/MsePlayer.tsx b/web/src/components/player/MsePlayer.tsx index 33ebbccf2..b699ae49b 100644 --- a/web/src/components/player/MsePlayer.tsx +++ b/web/src/components/player/MsePlayer.tsx @@ -117,12 +117,12 @@ function MSEPlayer({ }, [wsURL]); const onDisconnect = useCallback(() => { - setWsState(WebSocket.CLOSED); - if (wsRef.current) { + if (wsRef.current && wsState == WebSocket.OPEN) { + setWsState(WebSocket.CLOSED); wsRef.current.close(); wsRef.current = null; } - }, []); + }, [wsState]); const onOpen = () => { setWsState(WebSocket.OPEN);