If your client-side Netty channel write buffer is OutOfMemoryError and the server does not read it fast enough, you will see OutOfMemoryError on the client side. To avoid this, you should stop recording if Channel.isWritable() returns false . You will be notified with the channelInterestOpsChanged event when the status of Channel.writable' changes. Then, you can check again if Channel.writable' changes. Then, you can check again if Channel.isWritable () returns true` and continues recording.
If it is normal to discard pending data, I would simply not call Channel.write() if Channel.isWritable() returns false .
You can configure when the Channel.writable property Channel.writable changed using the watermark properties specified in the NioSocketChannelConfig . Also, check out the discard example that uses this technique.
source share