I have a java web application running on my private JVM on MochaHost. Application is running fine expect the websocket.
I have a websocket endpoint on my JAVA application. I use annotations.
@ServerEndpoint(value = "/websocket/chat/{room}", configurator = ServletAwareConfig.class)
My domain is www.instacollaboration.com. The application is working fine in general except my java script client cannot connect to the websocket server end point.
var Chat = {};
Chat.socket = null;
Chat.connect = (function(host) {
if ('WebSocket' in window) {
Chat.socket = new WebSocket(host);
} else if ('MozWebSocket' in window) {
Chat.socket = new MozWebSocket(host);
} else {
Console.log('Error: WebSocket is not supported by this browser.');
return;
}
Chat.socket.onopen = function() {
Console.log('Info: WebSocket connection opened. Meeting Room#' + myMeeringRoomNum);
document.getElementById('chat').onkeydown = function(event) {
if (event.keyCode == 13) {
Chat.sendMessage();
}
};
};
Chat.socket.onclose = function() {
document.getElementById('chat').onkeydown = null;
Console.log('Info: WebSocket closed.');
};
Chat.socket.onmessage = function(message) {
// Console.log(message.data);
processCommands(message.data);
};
});
Chat.initialize = function() {
var url = window.location.host + '/websocket/chat/';
if (window.location.protocol == 'http:') {
Chat.connect('ws://' + url + myMeeringRoomNum);
} else {
Chat.connect('wss://' + url + myMeeringRoomNum);
}
};
I am seeing this error.
Firefox can't establish a connection to the server at ws://instacollaboration.com/websocket/chat/Y6LA.
Am I missing something? Do mochahost support websockets?
My application and websocket connection run fine on my local tomcat server. This problem is only when running on remote server on MochaHost.