0
votes

Here's the story, I have a remote server and a client which behind a firewall. The client is implement by netty and it'll set up a keepalive connection to remote server. If there's no messages transfer in channel over 200 seconds, the firewall will reset the connection which is connect to remote server side, but the client side do not receive any tcp packets(such as RST package), so client consider that this connection is alive and the fact is not. So how to close the unusual connection forcedly before the firewall handle this keepalive connection incorrectly? BTW: I can't config the firewall

1

1 Answers

2
votes

For tcp connections, you should send something to detect if it's active or broken. So I suggest you do something like these:

  1. Let the client send a heartbeat packet regularly to keep the connection alive. By doing these, the firewall will keep the connection alive as you wish.

  2. When the connection is broken , you can get a error immediately after sending the heartbeat packet. So you can close the channel or reconnect it again.