How to get Netty websocket client example working

Posted by Paul Butcher on Stack Overflow See other posts from Stack Overflow or by Paul Butcher
Published on 2012-12-08T18:26:25Z Indexed on 2012/12/09 11:08 UTC
Read the original article Hit count: 348

Filed under:

I'm struggling to get the netty example websocket client working. I've compiled successfully with 4.0.0.Alpha8, but when I try to connect to a server (also a netty example) I get:

Exception in thread "main" io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response upgrade: websocket
    at io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13.finishHandshake(WebSocketClientHandshaker13.java:204)

which makes no sense to me whatsoever, given that this piece of code reads:

    String upgrade = response.getHeader(Names.UPGRADE);
    if (!Values.WEBSOCKET.equalsIgnoreCase(upgrade)) {
        throw new WebSocketHandshakeException("Invalid handshake response upgrade: "
                + response.getHeader(Names.UPGRADE));
    }

And as the message in the exception demonstrates, the Upgrade header does contain websocket as expected.

Any idea what's going on?

© Stack Overflow or respective owner

Related posts about netty