22

We have an Azure App Service Plan with 20+ applications.

One of the apps is causing port exhaustion. All the apps on the pricing plan lose connectivity as a result.

Tech support indicate TIME_WAIT status TCP connections are predominant when the port exhaustion happens. To help diagnose and monitor this and future situations, I want a general way of getting TCP connections and statuses per app.

Is this possible? If so how?

Sentinel
  • 3,582
  • 1
  • 30
  • 44
  • 1
    [IPGlobalProperties.GetActiveTcpConnections Method](https://msdn.microsoft.com/en-us/library/system.net.networkinformation.ipglobalproperties.getactivetcpconnections.aspx) could return TCP connections, but it does not work with Azure App Service. And Kudu debug console does not enable us to run ``netstat -n`` command to display the active connections being used by the TCP/IP protocol. I suspect that currently it does not enable us to get TCP connections per app. – Fei Han Nov 28 '16 at 10:12
  • 3
    I see this as a flaw. Tech support @ MSFT seem as though they are also having great difficulty helping with our case. I am not sure how to proceed in diagnosing the cause of the port exhaustion. – Sentinel Nov 28 '16 at 15:32
  • 2
    The same issue. we have plenty outbound TCP connections and it is abnormal from our point of view. and it would be great to have some ability to diagnose exact hosts. – Ilya Oct 11 '18 at 15:19

2 Answers2

7

I realize this isn't a direct answer to your question, but we have a similar issue and found our use of HttpClient to be a contributing factor. If you're using a new HttpClient instance for each of your HTTP requests, you could be exhausting your available outbound connections. We found the following article to be very helpful in minimizing the number of outbound connections using HttpClient: https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/

We are also hoping for a way to view TCP connections from Azure App Services, since Kudu shows "Access Denied" when trying to use netstat.

rbakos
  • 89
  • 2
  • 2
    Thanks. I see the whole problem as a design oversight in Azure PaaS. All other resource usage can result in auto scale or alerting. Port consumption is poorly handled in both of those – Sentinel Jan 04 '17 at 05:45
2

This is now a popular question. To add some extra info, the outcome of the investigation was that one app was using a MySQL client library that had some kind of bug. It was not closing TCP ports correctly. This killed the whole plan. After talking with Azure tech support they agreed that there should be improved reporting of TCP connectivity in the Azure portal. Since then I have not checked if there have been any improvements.

Sentinel
  • 3,582
  • 1
  • 30
  • 44