Trouble with Netty IdleStateHandler - am I testing it the wrong way?

后端 未结 2 1193
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 11:18

I have a toy Netty server and am trying to send heartbeat messages to clients when nothing has happened on their channels. I am testing this by telnetting to the server, writing

2条回答
  •  情书的邮戳
    2021-02-01 11:45

    Norman’s answer is a really helpful,but what I'd like to point out another thing: the idleStateHandler and the heartbeatHandler should be channel specific, so in the PipeLineFactory , you shouldn't construct these two handlers as private members, but need to create new ones in the getPipeline() method. You's also have a channel map to save the constructed channels, if you need to release them, you'd better also stop the timer to release the resources.

提交回复
热议问题