JS监听WebSocket是否处于关闭状态:
var socket = new WebSocket("localhost:8080/websocket"); if(socket.readyState != socket.OPEN){ alert("连接已中断!") //todo... return false; }