The only “safe” way is to have your application send some kind of “keep alive” messages from time to time. SO_KEEPALIVE is not really good enough for this.
> On 15. Feb 2018, at 10:12, Per Steffensen <[email protected]> wrote: > > Hi > > I made a client-server system using Netty. The server is running in DMZ and > the client in SZ, so only the client can establish the connection. The client > establishes the connection and a few messages is exchanged. After than > silence, except when the server needs to send something to the client, but it > can be hours or days in between. It is working fine, except that the > connection is broken, when the server wants to send something to the client, > if "enough" time has passed since the last message exchange. It seems to be 2 > hours that is the limit. The symptoms are that the server tries to send the > message, but it cannot do it, it gets "Connection reset by peer". The server > cannot reestablish the connection. It is the responsibility of the client to > make sure that the connection is up, and it does so by reestablishing in case > it notices it is down. The problem (using Netty 4.1.16.Final) is that the > client is never notified (via channelInactive) that the connection is down, > so it will not reestablish. Net-result is that the server cannot send the > message to the client. I have upgraded to 4.1.21.Final, and now it seems > (havnt tested thoroughly yet) that the client is actually notified, and it > can reestablish. But I would rather that the connections are not being shut > down automatically behind the scenes. I have added SO_KEEPALIVE all kinds of > places, but it does not seem to change the behavior. Any idea why the > inactive connections are automatically shut down? And how to avoid it? I have > several connections, and for most of them it is fine that they are shut down > if there is no activity, put for a particular connection it would be nice if > it is not. So being able to avoiding the automatic shutdown on a > per-connection-basis would be optimal. > > Regards, Per Steffensen > > -- > You received this message because you are subscribed to the Google Groups > "Netty discussions" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/netty/5fe219c7-34cf-4491-a608-26561357d600%40googlegroups.com > > <https://groups.google.com/d/msgid/netty/5fe219c7-34cf-4491-a608-26561357d600%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Netty discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/netty/A48CF16A-B64E-4299-9DE9-C51DD5C4B332%40googlemail.com. For more options, visit https://groups.google.com/d/optout.
