websocket 需要保持長時間連接揖曾,需要增加心跳檢測丹壕。
具體方法:
_this.websocket.onopen = function(){
console.log('open')
setInterval(function(){
_this.websocket.send({a:"a"}) //此處只是保持心跳,發(fā)送的內容無意義 //2min發(fā)送一次
},20000)
};