An attempt was made to access a socket in a way that is denied by its access permissions in Azure Web Apps

I run webapi on an Azure website that calls external web service calls. Webapi processes approximately 2K-3K requests per minute.

Periodically, many socket errors begin, indicating: "An attempt was made to access a socket that was denied by its access permissions." This error occurs regardless of the IP address of the external web service.

At first I thought it might be an ephemeral port depletion, but I limited the "connectionManagement" to 100 connections.

What could be the reason for this?

Thank you very much. We are pleased to provide any information that may be useful.

Update 6/1: - does not work on 6/2

I added the following to the web.config system.net section:

<defaultProxy enabled="false" useDefaultCredentials="false"> <proxy/> <bypasslist/> <module/> </defaultProxy> 

This seems to have helped since I have not seen this problem in the last 6 hours. I have no idea why this will really help, since I do not use things related to proxies.

Any thoughts?

Update 6/2:

Adding the defaultProxy property doesn't really help. The problem is still happening. Return to the drawing board.

+6
source share
1 answer

I finally figured out the cause of this problem. The problem arose due to port depletion.

I used the NLog email target, which over time captured and held too many SMTP connections (despite limiting 100 max connections). After deleting the email target, the problem no longer occurs. I did not understand why NLog exhibits this behavior.

+2
source

Source: https://habr.com/ru/post/987689/


All Articles