22

I have a website running as a web app on a dedicated Azure plan. It connects to a Redis, SQL Azure and a MongoDB backend. The website has been running fine for weeks now and then without any new code I am now getting lots of socket exceptions starting like the one below.

An attempt was made to access a socket in a way forbidden by its access permissions.

The website intermittently gets the error when connecting to Redis, SQL Azure and MongoDB which makes no sense. I changed the Pricing Tier for the site which would move the website from one VM to another behind the scenes and the errors went away for a couple days and have returned again.

I just now changed the site from an S3 to an S2 (making it smaller) and they have gone away but I don't know for how long. How do I fix this? Does Azure limit the number of sockets for a site? Is there some setting on a site in Azure that could cause this?

Joseph Idziorek
  • 4,853
  • 6
  • 23
  • 37
runxc1 Bret Ferrier
  • 8,096
  • 14
  • 61
  • 100
  • Not sure what's causing your error, but to answer your question about limits on # of sockets: The free/shared/basic tiers limit # of sockets, but standard tier does not, according to the latest [pricing page](http://azure.microsoft.com/en-us/pricing/details/websites/). – David Makogon May 27 '15 at 13:09
  • Do you have access to a support plan for Azure? – Dan Field May 27 '15 at 17:43
  • I currently do not have access to a support plan for Azure. Currently it seems as though one in 100 requests continues to get this error. It sure seems like it is a firewall issue in Azure but don't know how that could be. – runxc1 Bret Ferrier Jun 02 '15 at 16:44
  • Azure might have some socket limit for sure, as number of ports are limited to 64k, however, looks like the error is in the library that opens socket but does not close it. – Akash Kava Jun 06 '15 at 09:27

6 Answers6

7

I had the same problem and there was a very trivial reason for it: My ApiUrl connectionString replacement wasn't being completed successfully. That meant that my Webapp was trying to link with a localhost app, which would be forbidden.

In essence: troubleshoot your Configuration variables before making any conclusions.

GeorgiG
  • 1,018
  • 1
  • 13
  • 29
  • 1
    The trivial answers are my favourite. Thanks, this helped me solve. Did search for 'localhost' and found somewhere hardcoded by another dev. – Shumii Sep 15 '21 at 10:32
4

Indeed, it does limit the amount of sockets. As far as I know, this isn't documented anywhere official. I do, however, have a blog post on this here: http://www.freekpaans.nl/2015/08/starving-outgoing-connections-on-windows-azure-web-sites/

Freek
  • 1,506
  • 1
  • 11
  • 25
2

I was getting the same error in the last few weeks. To fix that i deleted my website from azure and i redeployed using a different name. I know it is weird but when i deleted from azure and redeployed using the same name i got the same error again.

0

I faced this issue because I added to the web app a path mapping and new application. The new asp.net core application had different versions of the dependencies which it shared with the existing one.

Something about that was causing neither of them to be able to run. When I synchronized my dependencies between projects, all the applications on my app service began working correctly again.

sirdank
  • 3,351
  • 3
  • 25
  • 58
0

I have faced this issue today. I had a function app configured, using a hybrid connection.

The hybrid connection was configured to use http, while my azure functions app was configured to use https.

Changing the app to use http, solved the issue. (I guess changing the hybrid connection to https would also resolve the issue.)

Henrik Gering
  • 1,769
  • 16
  • 29
0

In my case, I had correctly created the relay and the Hybrid Connection, but I had failed to add my new Hybrid Connection to my App Service's configuration. Once I went to the Networking -> Hybrid connections settings of my App Service and added the Hybrid Connection, everything started working.

Paul Trotter
  • 77
  • 1
  • 9