After 2 days of try and error I finally get the result I want. But I think this is the dumbest way to check Websocket connection.

The internet suggestions that I should use try and catch. But never play with it before I have no idea where to begin with.
Code:
var ws = "ws://75.98.171.173:8008"
  , ww = "ws://75.98.171.173:8080";

var x = new WebSocket(ws);
x.onopen = function() {
	xx(ws);
};

var y = new WebSocket(ww);
y.onopen = function() {
	xx(ww);
};

var xx  = function(w) {
	yy(y);
};

var yy = function(i) {
	console.log(i);
};
The reason I check WebSocket connection is that some places have blocked a certain port connection such as workplace blah blah blah (port 80 is being use by PHP --> Apache to be exact). With port availability check up, people may be able to access to my app from anywhere.

PS: some place does not block any port and I want I use only one port at the time.
Thank you,