如何在Netty 3.3中配置WebSocket(RFC 6455)?

如何在Netty 3.3中配置WebSocket(RFC 6455)?,websocket,netty,Websocket,Netty,我有Netty 3.3服务器和来自 我有一个实现RFC6455的客户端,但默认情况下服务器无法解码它的消息。调试时,我看到使用了WebSocket08FrameDecoder(而不是WebSocket13FrameDecoder)。当我将客户端降级为draft00时,一切正常。 如何配置Netty来解码RFC 6455消息 更新 客户端发送此握手包: GET /websocket HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Sec-WebSoc

我有Netty 3.3服务器和来自

我有一个实现RFC6455的客户端,但默认情况下服务器无法解码它的消息。调试时,我看到使用了WebSocket08FrameDecoder(而不是WebSocket13FrameDecoder)。当我将客户端降级为draft00时,一切正常。 如何配置Netty来解码RFC 6455消息

更新

客户端发送此握手包:

GET /websocket HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: 5a087
Host: 127.0.0.1
Origin: 127.0.0.1
服务器上的握手器是
WebSocketServerHandshaker13
,但我仍然收到错误信息:

org.jboss.netty.handler.codec.frame.CorruptedFrameException: unmasked client to server frame
at org.jboss.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.protocolViolation(WebSocket08FrameDecoder.java:350)
at org.jboss.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.decode(WebSocket08FrameDecoder.java:138)
at org.jboss.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.decode(WebSocket08FrameDecoder.java:56)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:465)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:438)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:343)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)`
如果查看,它将根据HTTP头中传递的web套接字版本来实例解码器

 public WebSocketServerHandshaker newHandshaker(HttpRequest req) {

    String version = req.getHeader(Names.SEC_WEBSOCKET_VERSION);
    if (version != null) {
        if (version.equals(WebSocketVersion.V13.toHttpHeaderValue())) {
            // Version 13 of the wire protocol - RFC 6455 (version 17 of the draft hybi specification).
            return new WebSocketServerHandshaker13(webSocketURL, subprotocols, allowExtensions);
        } else if (version.equals(WebSocketVersion.V08.toHttpHeaderValue())) {
            // Version 8 of the wire protocol - version 10 of the draft hybi specification.
            return new WebSocketServerHandshaker08(webSocketURL, subprotocols, allowExtensions);
        } else {
            return null;
        }
    } else {
        // Assume version 00 where version header was not specified
        return new WebSocketServerHandshaker00(webSocketURL, subprotocols);
    }
}

请检查您的客户端实现,以查看它在HTTP头中发送的版本。应该是
Sec WebSocket Version:13

我在应答中添加了客户端握手包和调试日志这应该是客户端屏蔽中的问题。谢谢你的回复。