本文介绍了Netty:关闭频道时,ClosedChannelException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么当我试图关闭频道时,我抛出了ChannelClosedException?用Channel.close()关闭,异常的堆栈跟踪:

Why when i'm trying to close channel, I got ChannelClosedException thrown?Closing with Channel.close(), exception's stacktrace:

java.nio.channels.ClosedChannelException
    at org.jboss.netty.channel.socket.nio.NioWorker.cleanUpWriteBuffer(NioWorker.java:645)
    at org.jboss.netty.channel.socket.nio.NioWorker.close(NioWorker.java:601)
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleAcceptedSocket(NioServerSocketPipelineSink.java:119)
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:76)
    at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:60)
    at org.jboss.netty.channel.Channels.close(Channels.java:720)
    at org.jboss.netty.channel.AbstractChannel.close(AbstractChannel.java:200)
    at ru.greencubes.player.PlayerWorkerThread.closeConnection(PlayerWorkerThread.java:107)
    at ru.greencubes.player.PlayerWorkerThread.shutDown(PlayerWorkerThread.java:282)
    at ru.greencubes.player.NetworkPlayerThread.disconnect(NetworkPlayerThread.java:1289)
    at ru.greencubes.player.NetworkPlayerThread.disconnect(NetworkPlayerThread.java:1272)
    at ru.greencubes.server.Server.run(Server.java:1590)
    at ru.greencubes.server.ServerThread.run(ServerThread.java:12)

推荐答案

我认为您应该忽略这一点.它只是告诉您,当它试图将剩余字节写入该通道时,该通道已经关闭.所以没什么好担心的.

I think you should just ignore this. It just told you that the channel was already closed when it tried to write the remaining bytes to the channel. So nothing to worry about.

这篇关于Netty:关闭频道时,ClosedChannelException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 15:59