netty / netty

Netty project - an event-driven asynchronous network application framework
http://netty.io
Apache License 2.0
33.3k stars 15.89k forks source link

io.netty.handler.codec.CorruptedFrameException: RSV != 0 and no extension negotiated, RSV:1 #5070

Closed vitaliy-kuzmich closed 4 years ago

vitaliy-kuzmich commented 8 years ago

Hello, I have this exception, at 4.1.0.CR6 but at 4.1.0.Beta8 works well. What I did wrong? Currently I am using custom Handshaker, with 13 version (WebSocketClientHandshaker13) .

io.netty.handler.codec.CorruptedFrameException: RSV != 0 and no extension negotiated, RSV:1
    at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.protocolViolation(WebSocket08FrameDecoder.java:412)
    at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.decode(WebSocket08FrameDecoder.java:188)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:387)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:245)
    at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
    at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:154)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:354)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:145)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:1078)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:127)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:527)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:484)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:398)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:370)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

I tried to set "allowExtensions" but then with

io.netty.handler.codec.CorruptedFrameException: data frame using reserved opcode 7
    at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.protocolViolation(WebSocket08FrameDecoder.java:412)
    at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.decode(WebSocket08FrameDecoder.java:229)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:387)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:245)
    at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
    at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:154)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:354)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:145)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:1078)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:127)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:527)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:484)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:398)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:370)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

reproduce: try to connect to lightstreamer server. via wss

vitaliy-kuzmich commented 8 years ago

just tried 4.1.0.CR1, it also does not works. What is the changes in frames between 4.1.0.Beta8 and 4.1.0.CR1 ? upd: I found that there is problem with proxy, I used HttpProxyHandler.

vitaliy-kuzmich commented 8 years ago

upd: wss does not working with proxies. But worked before.

normanmaurer commented 8 years ago

@vitaliy-kuzmich can you give us a reproducer ?

vitaliy-kuzmich commented 8 years ago

https://github.com/vitaliy-kuzmich/reproducer5070 to fix: cut HttpProxyHandler handler from WSInitializer or change netty version to 4.1.0.Beta8 in pom.xml

normanmaurer commented 8 years ago

@vitaliy-kuzmich what I'm expected to see when it works ?

vitaliy-kuzmich commented 8 years ago

@normanmaurer "CloseWebSocketFrame Cannot continue due to an unexpected error" it is mean then WS parsed well....

normanmaurer commented 8 years ago

@vitaliy-kuzmich did you also try to test it by have the proxy (little-proxy) and your code run in two different JVMs ? As maybe the little-proxy is prepared to take the latest CR releases in terms of changes.

vitaliy-kuzmich commented 8 years ago

firstly I got this error at external proxy service... I found that same error occures with little-proxy also, so I used it to reproduce and exclude external services which is easier.

vitaliy-kuzmich commented 8 years ago

@normanmaurer no I did not test it on different JVMs.

normanmaurer commented 8 years ago

@vitaliy-kuzmich ah ok... thanks!

normanmaurer commented 8 years ago

@vitaliy-kuzmich just checked and I can not reproduce with latest code from 4.1 branch. Can you try with 4.1.0.Final-SNAPSHOT and check if you can not reproduce anymore as well ?

normanmaurer commented 8 years ago

hmm something is still wrong. let me investigate

normanmaurer commented 8 years ago

@vitaliy-kuzmich ok I know whats going on.... let me think about a way to fix it.

normanmaurer commented 8 years ago

@vitaliy-kuzmich basically the HttpClientCodec of HttpProxyHandler is removed by mistake.

vplewis commented 8 years ago

I am having this exact issue with 4.1.5 Final. Sorry Actually I am gettting RSV:4 io.netty.handler.codec.CorruptedFrameException: RSV != 0 and no extension negotiated, RSV:4 at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.protocolViolation(WebSocket08FrameDecoder.java:412) at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.decode(WebSocket08FrameDecoder.java:188) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)

PhilLehmann commented 7 years ago

RSV 4 seems to be connected to another issue: https://github.com/netty/netty/issues/5837.

PhilLehmann commented 7 years ago

I can reproduce this issue (wss over proxy => CorruptedFrameException: RSV != 0 and no extension negotiated, RSV:1) with VertX 3.3.3 which uses netty 4.1.5.Final.

From the comments, it looks like @normanmaurer has resolved the issue - but it is still open. Will this be merged or should it already be fixed?

Thanks! :smile:

fenik17 commented 7 years ago

Will this be merged or should it already be fixed?

Obviously, the fix was included in a later version than 4.1.5.

wojciechkumon commented 7 years ago

I'm facing "io.netty.handler.codec.CorruptedFrameException: RSV != 0 and no extension negotiated, RSV:1" (vertx 3.4.1, wss over proxy), can I do anything or should I just wait for new version?

PhilLehmann commented 7 years ago

VertX 3.4.1 (which is the latest release of VertX) uses netty 4.1.8.Final (released Jan 2017).

It actually looks like the corresponding pull request https://github.com/netty/netty/pull/5329 was never merged.

wojciechkumon commented 7 years ago

Any chance to merge it and use in next release?

PhilLehmann commented 6 years ago

@normanmaurer any chance to merge your solution to this issue - was it commit https://github.com/netty/netty/commit/387bb09f9a97c4c2e6a3c461bed0666f5cd59277 ?

johnou commented 6 years ago

@philrykoff he is off on holiday now, if you take that commit, rebase it, and address the comments Trustin left in a new PR I think that would help a lot.

ted-wq-x commented 6 years ago

@philrykoff i use vertx 3.4.2 also has this problem ,do you have any idea to fix this?

PhilLehmann commented 6 years ago

I have never worked "in" netty, so I am a bit hesitant to rebase that PR myself. I am currently wrapping up a project and get back to this afterwards.

ted-wq-x commented 6 years ago

The default value is http so i set the type to socks5,hahaha,but I don’t know why netty doesn’t support https?

在 2017年10月13日,下午3:28,Phil Rykoff notifications@github.com<mailto:notifications@github.com> 写道:

hesitant

amotech-tm commented 6 years ago

Hi - I have the same problem with vertx 3.5.1 / netty 4.1.19.Final / wss over proxy Are there any plans to fix this ? Best regards Thomas

valodzka commented 6 years ago

@normanmaurer any particular reason why 387bb09f9a97c4c2e6a3c461bed0666f5cd59277 is not merged? Any plans to do it?

kedarw commented 5 years ago

Hi, I am also facing same issue. Is there plan to merge fix in any of upcoming releases?

Also others who faced same issue, found way to get around? Can you please describe what you did? Thanks in advance.

Just for reference exception I saw:

    at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.protocolViolation(WebSocket08FrameDecoder.java:412)
    at io.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder.decode(WebSocket08FrameDecoder.java:188)
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1336)
    at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1127)
    at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1162)
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:934)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
    at java.lang.Thread.run(Thread.java:745)
ghost commented 5 years ago

@kedarw I found a workaround: https://github.com/TakahikoKawasaki/nv-websocket-client This is websocket client library supporting wss and proxy. I replaced vertx websocket client with this. Works in production :)

kedarw commented 5 years ago

Thanks @wojtas626, appreciate your help. I will try nv-websocket-client.

rgmz commented 5 years ago

Hi - I have the same problem with vertx 3.5.1 / netty 4.1.19.Final / wss over proxy Are there any plans to fix this ? Best regards Thomas

I am still experiencing this issue in Vert.x 3.7.0 / Netty 4.1.30.Final 😞.

luckyyuandm commented 5 years ago

The problem is that the WebSocketClientHandshaker put ws-decoder(ws-encoder) in the wrong place in the ChannelPipeline. The WebSocketClientHandshaker find the position where the ws-decoder(ws-encoder)was put in the ChannelPipeline by locating the first io.netty.handler.codec.http.HttpClientCodec. details :https://github.com/netty/netty/issues/5201#issue-152789771 workaround:rewrite HttpProxyHandler and HttpClientCodec which HttpProxyHandler referenced, change the package name. Make sure HttpClientCodec which HttpProxyHandler referenced in the channelpipeline is different from io.netty.handler.codec.http.HttpClientCodec。

hengyunabc commented 5 years ago

Version: 4.1.38.Final

Change

pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, true));

to

pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true, 65536, false, true, 10000L));

Resolved my problem.