My application uses Netty 4.x with TCP sockets to distribute the same data to multiple clients. I want my application to tolerate some clients stalls in data receiving, but if client is too slow I want my application to abandon (close) the connection.
If I understand correctly I can achieve this by configuring proper:
- sendBufferSize (as far as it allowed by underlying OS)
ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK
.
Netty Channel.write()
writes to ChannelOutboundBuffer
. The contents of ChannelOutputBuffers
is written to NIO SocketChannel. The operating system sends data by TCP to client.
If client does not read its socket on time, the OS socket sendBuffer
fills up, then ChannelOutboundBuffer
fills up as far as WRITE_BUFFER_HIGH_WATER_MARK
is reached. Next the channel gets unwrtitable state (to avoid out of memory).
What is Netty closing channel policy in this situation ? Does Netty close channel if handlers keep writing to it despite it is not writable ?
Thanks in advance for any advise.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…