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

Viewed 66

I have already active connection list.

enter image description here

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();
};
0 Answers
Related