title: How to keep TCP connections alive on AWS network loadbalancer
body: <p>Architecture:<br>
  We have a bunch of IoT devices connected via an AWS network loadbalancer (NLB) to our backend servers.
  This is a bidirectional channel (not a request response style, but messages passed from either party to the other).  </p>
  
  <p>Objective:<br>
  How to keep connections (both sides of NLB) alive during inactivity.  </p>
  
  <p>Description: 
  Frequently clients go to inactive mode and do not send (or receive) anything to (or from) servers. If this state lasts longer than 350 seconds (connection idle timeout value of NLBs) the LB silently kill the connection. This is bad, because we see a lot of RST packets everywhere.</p>
  
  <p>Questions:  </p>
  
  <ol>
  <li>I'm aware of <code>SO_KEEPALIVE</code> feature and can enable it on our backend servers. This keeps the connection between backend servers and NLB alive. But what about clients? Do NLBs forward TCP keep-alive packets to the other party? (<a href="https://forums.aws.amazon.com/thread.jspa?threadID=167188" rel="nofollow noreferrer">Here</a> it says it does not). If it does not, how to keep clients connections open? (At them moment, I'm thinking to send an empty message to keep the connection.)</li>
  <li>Is this behavior specific to AWS NLBs or do loadbalancers generally work this way?</li>
  </ol>