We are using Oauth to authenticate our cloud service in Azure using SharePoint online - https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/three-authorization-systems-for-sharepoint-add-ins#low-trust and we are getting this error - System.Net.Sockets.SocketException: 'An existing connection was forcibly closed by the remote host'
When trying clientContext.ExecuteQuery() code below.
Microsoft.SharePoint.Client.User spUser = null;
try
{
using (clientContext)
{
if (clientContext != null)
{
spUser = clientContext.Web.CurrentUser;
clientContext.Load(spUser);
clientContext.ExecuteQuery();
return spUser.LoginName.Split('|')[2];
}
}
return string.Empty;//no context = no id
}
Any idea what this issue could be or how to troubleshoot this? Thanks