app.js:2 WebSocket connection to 'wss://events.pima-uae.com:6001/app/anyKey?protocol=7&client=js&version=6.0.3&flash=false' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED code example

Example: javascript websocket example code

var Socket = new WebSocket('ws://' + window.location.hostname + ':81/'); // The '81' here is the Port where the WebSocket server will communicate with
// The instance of the WebSocket() class (i.e. Socket here), must need to be globally defined

Socket.send("pass your data here, and it'll be String"); // This method one can call locally