                 clearInterval(connectionTimer);
                    connectionTimer = null;
                }

                document.getElementById('connectBtn').disabled = false;
                document.getElementById('disconnectBtn').disabled = true;
            };

            socket.onerror = function (error) {
                addMessage('error', `WebSocket error: ${error}`);
                console.error('WebSocket error:', error);
            };
        }

        function disconnect() {
        