Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm running a webapi on an Azure website that makes calls to external web services. The webapi handles approximately 2K-3K requests per minute.

Periodically, lots of socket errors start occurring that indicate: "An attempt was made to access a socket in a way forbidden by its access permissions". This error seems to occur regardless of the ip address of the external web service.

At first, I thought it might be ephemeral port exhaustion, but I've limited "connectionManagement" to a maximum of 100 connections.

What would be causing this?

Thanks very much. Happy to provide whatever information might be helpful.

Update 6/1: - doesn't work per 6/2

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

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

It appears to have helped as I haven't seen this issue in the last 6 hours. I have no idea why this would actually help though as I'm not using any proxy-related stuff.

Any thoughts?

Update 6/2:

Adding the defaultProxy doesn't actually appear to help. The problem is still occurring. Back to the drawing board.

like image 748
Jonathan Avatar asked May 21 '15 19:05

Jonathan


1 Answers

I've finally figured out the cause of this problem. The issue was occurring due to port exhaustion.

I was using an NLog email target which was grabbing and holding onto too many SMTP connections over time (despite the 100 max connection limit). After removing the email target, the issue no longer occurs. I haven't figured out why NLog was exhibiting this behavior.

like image 148
Jonathan Avatar answered Sep 28 '22 00:09

Jonathan