Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

WebSocket connection failed: WebSocket opening handshake timed out

japochinoSep 2 2015 — edited Sep 10 2015

Hello

I'm trying to develop an application using websocket. But when I try to establish the connection sometimes (yes, sometimes) work and sometimes it doesn't and never get 101 response.

websocket.PNG

I have a javascript file with:

    var ws = new WebSocket("ws://" + document.location.host + "/chp/mediador");

and in the ServerEndpoint (named Mediador) the code in my onOpen method is executing. This is the code of this method:

    @OnOpen

        public void onOpen(Session sesion) {

        LOGGER.log(Level.INFO, "Mediador.onOpen: sesion id: {0}", sesion.getId());

    }

I can see the message: "Información:   Mediador.onOpen: sesion id: X" (X is the number of the session -1,2,3,4...-)

But the next code in the javascript file:

    ws.onopen = function (evento) {

    console.log("websocket en " + document.location.pathname + " abierto");

    ...

never executes and after about 4 minutes my chrome console show the error:

"WebSocket connection to 'ws://localhost:8080/chp/mediador' failed: WebSocket opening handshake timed out"

I have disabled the firewall and have no antivirus installed in my server.

I'm using Chrome 44.0.2403.157


Can you help me?

Thanks!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 8 2015
Added on Sep 2 2015
2 comments
8,343 views