title: Azure webapp load balance time out issue,getting HTTP status of 500 and sub status of 121
body: <p>We have a web site which load and analyse excel data and report back to the user.Now the process of analyzing the excel data takes about on average over 5 minutes (depending on the data) during which time the client server communication seems to be idle.</p>
  <p>This web site is hosted on Azure as a webapp, and it seems that Azure has a load balancing time out according to the following link</p>
  <p><a href="https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/" rel="nofollow noreferrer">https://azure.microsoft.com/en-us/blog/new-configurable-idle-timeout-for-azure-load-balancer/</a></p>
  <p>in this link it is mentioned that</p>
  <blockquote>
  <p>In its default configuration, Azure Load Balancer has an ‘idle
  timeout’ setting of 4 minutes.</p>
  <p>This means that if you have a period of inactivity on your tcp or http
  sessions for more than the timeout value, there is no guarantee to
  have the connection maintained between the client and your service.</p>
  </blockquote>
  <p>because of this issue the end user constantly get HTTP status of 500 and sub status of 121.</p>
  <p>Currently we cant re-architecture the system nor able to change deploying as a webapp.</p>
  <p>We have tried to sending Jquery ajax request to the server on a set interval  but this doesn't seem to be working.</p>
  <p>The above article talks about keeping the TCP session alive using ServicePoint.SetTcpKeepAlive(), but we have no idea how to implement this in MVC web application.(Did not find any samples on the net either)</p>
  <p>We really need to resolve this issue because this could make or break our project.So any help is appreciated. specifically any working sample code using ServicePoint.SetTcpKeepAlive() in an MVC application is greatly appritiated</p>
  <p>Thanks in advance.</p>
  <p><strong>UPDATE</strong></p>
  <p>i tried out what Irb mentioned but still no luck.As you can see in the given image i call KeepSessionAlive repeatedly.At every call to KeepSessionAlive i access the Session Variable making sure not to time out the session.But still the call to Save returns 500. Again this only happens in Azure</p>
  <p><a href="https://i.stack.imgur.com/PG71U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PG71U.png" alt="enter image description here" /></a></p>