Client channel is not in writable state(NIO) Netty

北慕城南 提交于 2019-12-07 13:27:21

问题


client channel is not in writable state in netty . Can any experts guide me to find-out the reason

why the channel is always not in writable state?

since it is not in writable state our threads are in sleep mode. We analyzed the state of threads using Thread dump, added a counter in the following loop and it waits for a minute and then exit from the loop. But i really want to figure-out the reason for not writable state.

Is the channel is remains in ctx after the closing of channel(If the EOF is not send by the client)?

If can this happends (means never in writable state)?

while (!ctx.getChannel().isWritable()) {
    Thread.sleep(100);
    }

Please help.

Thank you very much


回答1:


Superficially, it is because the ChannelBuffer is full, i.e. no more writable bytes.

It could be caused by writing too fast, or the channel is not able to send out any bytes. If you're not writing anything too fast, perhaps it's because the channel never successfully sent out the bytes written.




回答2:


You should be using the selector, or whatever Netty gives you around it, to tell you when the channel is writable. You certainly shouldn't be literally wasting time by sleeping in a loop. The channel state can't change while you're doing that. It is only changed by select().



来源:https://stackoverflow.com/questions/15263180/client-channel-is-not-in-writable-statenio-netty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!