0

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.

Lamorak
  • 10,957
  • 9
  • 43
  • 57
  • I tried connecting to that endpoint with an echo websocket from the web, got this error: WebSocket connection to 'wss://instacollaboration.com/websocket/chat/Y6LA?encoding=text' failed: WebSocket opening handshake was canceled – toskv Aug 30 '15 at 15:28
  • definitely looks like there's something wrong with the server :-( – toskv Aug 30 '15 at 15:29

1 Answers1

0

Just chatted with MochaHost support. They don't support websocket on shared servers. I have to buy/rent a private server. :(