I am trying for making connection on web socket.But I’m unable to make it wait until server Started . Whenever I start my client without Server running I got caught in error event..What should I have to do to make my Client wait until Server get Start ?
My Client in Node.js
var WebSocket = require('ws');
var ws = new WebSocket('ws://localhost:90');
ws.on('open', function() {
console.log('Client 1 Started');
});
ws.on('message', function(message) {
console.log(message);
});
ws.on('error', function(err) {
console.log('Client Error :- ',err.code);
});
ws.on('close', function() {
console.log('Connection terminated..Closing Client 1');
});
Its Work For me…Now Client can wait still Server get Start…