2

In order to prevent OOME in a riemann server when clients do not read ACKs properly, I have implemented some logic to close the channel when it becomes unwritable, under the assumption this is caused by client not reading/ACKing packets quickly enough.

However, this also closes the channel when sending large-ish query results, probably because the server tries to write the result faster than it can be sent through TCP. Out of the top of my head, I would think the best way to handle this situation would be to set some timeout on writing, using a WriteTimeoutHandler.

Is there some standard pattern known in netty to handle that case?

insitu
  • 4,488
  • 3
  • 25
  • 42
  • Looks like this question is related: http://stackoverflow.com/questions/28862613/throttling-websockets-with-netty-socketio-server – insitu May 20 '16 at 13:37

1 Answers1

1

Basically you would stop writing once Channel.isWritable() returns false and start again once it returns true again. You can be notified by the update of this by overriding ChannelInboundHandler.channelWritabilityChanged(...).

Norman Maurer
  • 23,104
  • 2
  • 33
  • 31
  • Thanks for the proposal, that's something I had in mind but this seems quite complicated in this particular case as I need to handle some logic to know what kind of responses are not written. Is there a way to discard responses in the output buffer? In the end I am afraid there is no practical solution to what I want to do... – insitu Jun 01 '16 at 09:29