Forum Discussion

iPAHeartBeat's avatar
iPAHeartBeat
Copper Contributor
Feb 15, 2023

HttpClient Error; An attempt was made to access a socket in a way forbidden by its access permission

Hi Community

 

I have an Azure function app. I am facing the Socket access permission issue. 

 

Process detail:

The Azure Function App is getting called from the scheduler from Our Server every X Min. When it's being executed.

It will check for a particular status let's say `Start a Thread`. The function App will start a new thread and change the status `Thread is Running` and change it again to `Thread completed` once the task in the thread is completed.

 

This Thread created by Function is using HTTP Client to connect with another server to CRUD operation for different data based on unique identifiers. (No of Identifier need to process will vary from time to time)

 

Let's say we have to process 200 identifiers. Now Thread is processing all identifiers one by one (we do that as we don't want to overwhelm our server where we doing) Async CRUD operation.

 

The Issue:

Now we face the socket connection issue with the message. `An attempt was made to access a socket in a way forbidden by its access permissions. (xyz.server.com:port)`.

 

Reason for the Issue:

We neither have any idea about the cause of the issue nor are sure if the issue occurred at Azure Level due to some network setup or occurred from the server we are trying to connect to via HTTP Client. 

Please help us with how we can check the Azure side to identify the issue. We already Informed the Support team of the other server where CRUD operation happens.

 

Azure Function App Config

Region: US-West 2

OS: Window

Function Runtime: 4.15.2.20177

Mode: Run from Precompiled Package

 

App Code Setting

Framework: NET 6.0

C#: 10

Ready To Run: true

 

Network

Inbound Access Restriction: Off

Inbound App Assigned Address: off

Outbound VNET: N/A

Outbound Hybrid Connection: N/A

Outbound NAT Gateway: N/A

 

 

Edit 1:

This Stack overflow https://stackoverflow.com/questions/71164859/azure-function-an-attempt-was-made-to-access-a-socket-in-a-way-forbidden-by-its mentions the same kind of issue. Over there one answer suggests using `HttpWebRequest` and `HttpWebResponse` instead of `HttpClient`.

That I will check in some time if it fixes the issue or not?

No RepliesBe the first to reply

Resources