0

The behaviour of ReadTimeoutHandler seems to have changed in Netty 4 compared with Netty 3. In Netty 4 when the timeout fires, Netty not only raises a ReadTimeoutException but also closes the channel. This was not the case before. In Netty 3, the behaviour is to only raise the ReadTimeoutException, the channel is not closed.

I have a use case where I need to write a message to the channel, on timeout. This can't be done anymore because by the time, the code that handles the thrown ReadTimeoutException is reached, the channel is already closed.

Any tips/ideas on how to go about this use case in Netty 4? Basically write to the channel on ReadTimeoutException before Netty closes the channel?

dade
  • 3,340
  • 4
  • 32
  • 53
  • A working solution for now is to extend ReadTimeoutHandler and not close the channel in the readTimedOut implementation. Would be cool to see if someone more familiar with Netty has a more idiomatic approach – dade Feb 24 '21 at 15:15

1 Answers1

1

I think you may want to use IdleStateHandler which is more flexible in how you handle different types of idle events.

Norman Maurer
  • 23,104
  • 2
  • 33
  • 31