question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

exceptionCaught DecoderException: javax.net.ssl.SSLHandshakeException: error:1000009c:SSL routines:OPENSSL_internal:HTTP_REQUEST at random time

See original GitHub issue

Expected behavior

the exception throws from the exceptionCaught method,which extends SimpleChannelInboundHandler;

@Slf4j
@Service
@ChannelHandler.Sharable
public class ServerChannelInboundHandler extends SimpleChannelInboundHandler<StompFrame> {

  @Override
  public void channelActive(ChannelHandlerContext context) throws Exception {
    log.info("channel:{} active.", context.channel().id().asLongText());
  }

  @Override
  public void channelInactive(ChannelHandlerContext context) throws Exception {
    log.info("channel:{} inactive.", context.channel().id().asLongText());
    super.channelInactive(context);
  }

  @Override
  public void channelReadComplete(ChannelHandlerContext context) throws Exception {
    context.flush();
  }

  @Override
  public void exceptionCaught(ChannelHandlerContext context, Throwable e) throws Exception {
    **log.error("Unexpected exception occur,channel:{} will be closed, exception is:{} ",
        context.channel().id().asLongText(), e);**
        context.close();
  }
  @Override
  protected void channelRead0(ChannelHandlerContext context, StompFrame stompFrame) throws Exception { ...... }
}

the initializer is:

@Slf4j
@Service
public class WebSocketChannelInitializer extends ChannelInitializer<SocketChannel> {
  @Override
  protected void initChannel(SocketChannel socketChannel) throws Exception {

    ChannelPipeline pipeline = socketChannel.pipeline();
    DomainNameMapping<SslContext> domainNameMapping = sslFactory.newSslContext();
    if (domainNameMapping != null) {
      pipeline.addLast(new SniHandler(domainNameMapping));
    }

    pipeline.addLast("trafficHandler", trafficHandler);
    pipeline.addLast("stompDecoder", new StompSubframeDecoder());
    pipeline.addLast("stompEncoder", new StompSubframeEncoder());
    pipeline.addLast("aggregator", new StompSubframeAggregator(65535);
    pipeline.addLast(eventExecutorGroup, webSocketChannelInboundHandler);
  }
}

Actual behavior

18:04:52.015 195363572 ERROR   c.t.s.o.s.h.WebSocketChannelInboundHandler(57) - Unexpected exception occur,channel:001cacfffe1d3139-000025e7-00000006-72cf32c68d85b5a7-45441840 will be closed, exception is:{}
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: error:1000009c:SSL routines:OPENSSL_internal:HTTP_REQUEST
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:459)
	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.codec.ByteToMessageDecoder.handlerRemoved(ByteToMessageDecoder.java:236)
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:494)
	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:1414)
	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:945)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:146)
	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:886)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
Caused by: javax.net.ssl.SSLHandshakeException: error:1000009c:SSL routines:OPENSSL_internal:HTTP_REQUEST
	at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.shutdownWithError(ReferenceCountedOpenSslEngine.java:862)
	at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.sslReadErrorResult(ReferenceCountedOpenSslEngine.java:1110)
	at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1066)
	at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1132)
	at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1175)
	at io.netty.handler.ssl.SslHandler$SslEngineType$1.unwrap(SslHandler.java:216)
	at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1257)
	at io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1171)
	at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1205)
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
	... 23 common frames omitted

Netty version

  <dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>4.1.22.Final</version>
  </dependency>
  <dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-tcnative</artifactId>
    <version>2.0.7.Final</version>
  </dependency>
  <dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-tcnative-boringssl-static</artifactId>
    <version>2.0.7.Final</version>
  </dependency>

JVM version (e.g. java -version)

java version “1.8.0_121”

OS version (e.g. uname -a)

2.6.32-573.3.1.el6.x86_64 #1 SMP Thu Aug 13 22:55:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
horizonzycommented, Dec 20, 2018

@normanmaurer ,but there is no other users to access my code,only myself to access this function,and the error is not occured during my request,it just occured at random time

hi,have you solve it?I meet the same problem

I find the cause why the problem happen. In my project,I config the ssl,but some requests send by http.So errors occur

1reaction
normanmaurercommented, Dec 20, 2018

again if someone is doing http and not https on a port where SSL is used there is not much we can do about.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve javax.net.ssl.SSLHandshakeException Error?
First, you need to obtain the public certificate from the server you're trying to connect to. That can be done in a variety...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found