简体   繁体   中英

How to close websocket connection via already established websocket connection using websocket Resource Id?

I have already active connection list.

在此处输入图像描述

I have also all active connection resource Id, I want to when click Unlock then close connection.

I have try to close connection using JavaScript but it's generate new connection.

var socket = new WebSocket("ws://localhost:6001/ocpp/CP0002");
socket.onopen = function(event) {
  console.log("Connection established");
}

window.onbeforeunload = function() {
  socket.onclose = function () {
    console.log('Disconnected')
  }; // disable onclose handler first
  socket.close();
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM