title: Outbound connection timeout on Azure App Service
body: <p>We are hosting an <strong>ASP.NET Core MVC (2.2.6)</strong> application using <strong>Azure App Services</strong> (B2 plan, Linux-based container image, no replicas), that is firing off requests to a SOAP service (it is the service of an external vendor) with an average rate of 1 request every 3 minutes. No high load periods, the requests are scheduled to occur every few minutes.</p>
  
  <p>The application is working 99% of the time flawlessly, but there is a chance that after restarting the container (due to update or maintenance) from the Azure dashboard, the requests to the SOAP service start timing out (the timeout interval is set to 60 seconds). Sometimes the first 2-3 requests go through fine and then every single request times out. However, the application recovers every single time by itself within 1.5-2 hours and everything works fine until the next container restart.</p>
  
  <p>We used the <strong>WCF Web Service Reference</strong> tool of Visual Studio to generate the WCF client code and proxy class. We are also using the <code>ChannelFactory</code> class for channel reusability. During the time when we are experiencing the timeouts, I tried accessing the SOAP service using the built-in <code>HttpClient</code>, which also timed out. However, when I directly connect to the container using SSH and try to test the connection to the SOAP service with CURL, it is working. No timeouts from my local machine as well, of course.</p>
  
  <p>Here is a <code>netstat -peanut</code> snapshot while we are experiencing timeouts (I removed the non-relevant connections):</p>
  
  <pre><code>root@XXXXXXXXX:~# netstat -peanut
  Active Internet connections (servers and established)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name
  tcp        1      0 172.16.2.7:41451        XX.XXX.XX.XX:443        CLOSE_WAIT  0          6705221    1/dotnet
  tcp        0      1 172.16.2.7:45254        XX.XXX.XX.XX:443        SYN_SENT    0          6876809    1/dotnet
  tcp6       0      0 :::80                   :::*                    LISTEN      0          6703040    1/dotnet
  </code></pre>
  
  <p>When there are no timeouts, the one with <code>SYN_SENT</code> is not present.</p>
  
  <p>Did any of you guys experience something similar to this? Do you have a clue what could cause it?</p>