Unable to connect to the remote server System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 259
- Forks
- 161
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
Description
Discussed in https://github.com/pnp/pnpframework/discussions/482
Originally posted by vivekagrawal1110 October 5, 2021
I have ASP.Net Web API, to perform SharePoint operation using SharePoint add-in client context . I have deployed Web API on Azure Web Site.
Generally API works fine but randomly gives exception till that Web Site restarts manually.
System.Net.WebException: Unable to connect to the remote server System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 20.190.151.68:443
at System-NetSockets.Socket.DoConnect(EndPoint
endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketlnternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
End of inner exception stack trace
at System.Net.WebClient.DownloadDatalnternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadData(Uri address)
at System.Net.WebClient.DownloadData(String address)
at PnP.Framework.Utilities.TokenHelper GetMetadataDocument(String realm)
at PnP.Framework.Utilities.TokenHelper.GetStsUrl(String realm)
at PnP.Framework.Utilities.TokenHelper.GetAppOnlyAccessToken(String targetPrincipalName, String targetHost, String
targetRealm)
at PnRFramework.LJtilities.ACSTokenGenerator.GetToken(lJri siteurl)
at PnP.Framework.AuthenticationManager.b_56_0(String site)
at PnP.Framework.AuthenticationManager.
DisplayClass68_0.b 0(Object sender, WebRequestEventArgs args)
at Microsoft.SharePoint.Client.CIientRuntimeContext.OnExecutingWebRequest(WebRequestEventArgs args)
at Microsoft.SharePoint.Client.ClientContext.GetWebRequestExecutor()
at Microsoft.SharePoint Client ClientContext.GetFormDigestI nfoPrivate()
at Microsoft.SharePoint.Client ClientContext.EnsureFormDigest()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
Please help me to fix this issue.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the stack-trace entry points TokenHelper.GetMetadataDocument, TokenHelper.GetStsUrl, AuthenticationManager, and ClientContext.ExecuteQuery. Reproduce the intermittent Azure Web API failure and determine the conditions behind the socket access error; done means the cause is documented and the failure is addressed or clearly bounded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100