- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 netty 4.0.36.Final 编写客户端-服务器应用程序
一位测试工程师在客户端遇到了这个问题:
io.netty.handler.codec.DecoderException: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:418)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278)
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:962)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:485)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:399)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:101)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1072)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:904)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:387)
... 15 common frames omitted
channel 管道:
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(sslContext.newHandler(ch.alloc()));
pipeline.addLast(new AsnMessageDecoder());
pipeline.addLast(new AsnMessageEncoder());
pipeline.addLast(dataChannelHandler);
}
有时我会向管道添加另一个处理程序:
channel.pipeline().addFirst("idleStateHandler", new IdleStateHandler(180, 0, 0));
有两个 ChannelInboundHandler
public class AsnMessageDecoder extends ReplayingDecoder {
private static final Logger log = LoggerFactory.getLogger(AsnMessageDecoder.class);
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
DERCoder coder = Asn.getDERCoder();
coder.disableEncoderDebugging();
coder.disableDecoderDebugging();
coder.enableEncoderConstraints();
coder.enableDecoderConstraints();
coder.enableAutomaticEncoding();
coder.enableAutomaticDecoding();
coder.enableContainedValueEncoding();
coder.enableContainedValueDecoding();
try (ByteBufInputStream is = new ByteBufInputStream(in)) {
out.add(coder.decode(is, new Message()));
} catch (Exception e) {
log.error("Failed to decode message", e);
}
}
还有一个:
abstract class BaseChannelHandler<T extends ChannelContext> extends SimpleChannelInboundHandler<Message> {
private final Logger log = LoggerFactory.getLogger(getClass());
private final T channelContext;
private final ClientConfiguration clientConfiguration;
private final Writer writer;
private final ClientService service;
BaseChannelHandler(T channelContext,
ClientConfiguration clientConfiguration,
Writer writer,
ClientService service) {
this.channelContext = channelContext;
this.clientConfiguration = clientConfiguration;
this.writer = writer;
this.service = service;
}
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
log.debug("{} channelRegistered", getClass().getSimpleName());
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
log.debug("{} channelActive", getClass().getSimpleName());
channelContext.connectState();
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, Message msg) throws Exception {
log.debug("{} channelRead0 msg = {}", getClass().getSimpleName(), msg);
channelContext.handleMessage(msg);
if (clientConfiguration.isWritingOutputEnabled()) {
writer.writeXml(msg);
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
log.error(getClass().getSimpleName() + " exceptionCaught", cause);
ctx.close();
service.stop();
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
log.debug("{} channelInactive", getClass().getSimpleName());
}
@Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
log.debug("{} channelUnregistered", getClass().getSimpleName());
}
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
ctx.disconnect();
}
}
我无法重现问题。在我的本地机器上它工作正常。查看 wirweshark 并没有给我任何提示。看起来就像正常的断开连接。我不太确定接下来要做什么来解决这个问题。您能给我一些关于下一步解决这个问题的建议吗?
最佳答案
所以这似乎是 netty 版本(相当旧)中的一个错误。升级到4.1.24.Final修复了它。
关于java - Netty SslHandler 抛出 IllegalReferenceCountException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50170342/
我已经浪费了几天时间试图追踪新添加的 Akka 传输加密中的间歇性错误。 注意:我已经尝试在服务器和客户端之一或两者上设置 setIssueHandshake(true) ,但它根本没有帮助。 我们的
我正在使用 Netty 4.1.25。我在我的代码中从 pem 文件创建了一个 X509Certificate。使用该证书,我像这样设置 SslHandler: SslContext context
我们的部分应用程序需要在我们的 Netty 管道中删除/添加 SSL 处理程序,我们在 SSL 握手上设置超时以尝试阻止 Slowloris attacks .我们正在使用 Netty 4.1.44.
我正在使用 netty 4.0.36.Final 编写客户端-服务器应用程序 一位测试工程师在客户端遇到了这个问题: io.netty.handler.codec.DecoderException:
我正在努力解决 Netty 5.0.0Alpha1 的问题。目前我正在努力升级我们的一个 API 以使用 SSL。当我按照示例中所示设置所有内容时,服务器处理一个请求并崩溃。基本上,我能够在 fire
我在我的 Android 应用程序中使用 netty-3.6.6 SSL。 handshake() 实际上已经完成(Android 应用程序能够向/从 SSL 服务器发送/接收数据)但是 operat
我是一名优秀的程序员,十分优秀!