title: System.Net.Sockets.SocketException: 'An existing connection was forcibly closed by the remote host' with SharePoint Online low trust authentication
body: <p>We are using Oauth to authenticate our cloud service in Azure using SharePoint online - <a href="https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/three-authorization-systems-for-sharepoint-add-ins#low-trust" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/three-authorization-systems-for-sharepoint-add-ins#low-trust</a> and we are getting this error - System.Net.Sockets.SocketException: 'An existing connection was forcibly closed by the remote host'</p>
  
  <p>When trying clientContext.ExecuteQuery() code below.</p>
  
  <pre><code>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
              }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/WyGAV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WyGAV.png" alt="This is how SharePoint Context looks like"></a></p>
  
  <p>Any idea what this issue could be or how to troubleshoot this? Thanks</p>