Closed ganzr closed 4 years ago
What protocol do you use? bolt or h2c ? Can you provider a demo for us to reproducing it ? I think it is not sofa-rpc's behavior to create connection with aliyun. We need more information to find the cause of this problem. @ganzr
i use h2 for tls. At first i use bolt, and nothing wrong happen. But when i change to h2, exception throw
I can try to write a demo
Demo like this testDemo.zip
and it will throw exception like this:
@ganzr The demo runs well in my local env, when I call http://localhost:8080/service/test
.
You can debug into Http2ClientInitializer
at line 116:
if (ApplicationProtocolNames.HTTP_2.equals(protocol))
At my situation, protocol
is "h2"
Your question
when i run my program, it throw an exception: 2020-05-13 15:00:44.547 WARN i.n.channel.DefaultChannelPipeline.warn:151 - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. java.lang.IllegalStateException: unknown protocol: at com.alipay.sofa.rpc.transport.http.Http2ClientInitializer$1.configurePipeline(Http2ClientInitializer.java:123) at io.netty.handler.ssl.ApplicationProtocolNegotiationHandler.userEventTriggered(ApplicationProtocolNegotiationHandler.java:92) at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:329) at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:315) at io.netty.channel.AbstractChannelHandlerContext.fireUserEventTriggered(AbstractChannelHandlerContext.java:307) at io.netty.handler.ssl.SslHandler.setHandshakeSuccess(SslHandler.java:1530) at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1368) at io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1211) at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1245) 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:1434) 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:965) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:628) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) at java.lang.Thread.run(Thread.java:745)
my program can keep running, but this exception is thrown continually. it seems that this exception is thrown in the process of NioEventLoop when there is a SslHandshakeCompletionEvent. So why will this happen? I didn't even run another peer.
Your scenes
My program is run in an distributed system, when it starts, peer will build up it ssl connection will all the peer it knows. What makes me confused is that, when i run the same program with same code in another host machine, it won't throw this exception. I have checked all the configuration and dependency between this two projects, but i can't find any differences between them.
Your advice
since i don't know why sslhandshakeCompletion will happen when i only run a peer, i use wireshark to check who is negosiation with my program. And it turns out to be some aliyun server. Sofarpc use netty as basic model, but why the java.lang.IllegalStateException: unknown protocol will be thrown in the negosiation whith some unkown server?
Environment
java -version
):uname -a
):