监听close进行重连
<!DOCTYPE HTML>
<html>
<head>
<title>WebSocket</title>
<script src="jquery.min.js"></script>
<script src="ws.js"></script>
</head>
<body>
<button id="close">close</button>
</body>
</html>
var accessToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIgJI";
var globalwebsocket = null;
$(function() {
if ('WebSocket' in window) {
websocketLifePeriod();
} else {
alert("unsupported websocket");
}
$("#close").click(function() {
closeWebSocket();
})
})
function websocketLifePeriod() {
var websocket = new WebSocket("ws://7k586s.natappfree.cc:80/yiliao/websocketServer/" + accessToken);
globalwebsocket = websocket;
web