I've been working in a sandbox SharePoint site and using PnP.Framework and Microsoft.SharePointOnline.CSOM to build something my company can use for managing files programatically.
The following code actually worked for the first 10 minutes or so of debugging then starting giving me an SSL error. For reference, this is just a console app I'm using to get my head around the API.
The code:
string clientId = "*********";
string redirectUrl = "http://localhost";
string tenantId = "************";
string siteUrl = "https://5klmt2.sharepoint.com/sites/TestTeam";
var authMan = PnP.Framework.AuthenticationManager.CreateWithInteractiveLogin(clientId, redirectUrl, tenantId);
using (ClientContext context = authMan.GetContext(siteUrl))
{
var web = context.Web;
context.Load(web, w => w.Id, w => w.Title);
context.ExecuteQuery();
Console.WriteLine($"{web.Id} - {web.Title}");
var documents = web.GetListByTitle("Documents", l => l.Id, l => l.Title);
Console.WriteLine($"{documents.Id} - {documents.Title}");
}
It breaks when it tries to ExecuteQuery, giving me the following error:
System.Net.WebException
HResult=0x80131620
Message=The SSL connection could not be established, see inner exception.
Source=System.Net.Requests
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at Program.<TestStuff>d__1.MoveNext() in C:\Club Benchmarking\GitHub\SharePointCSOM\SharePointCSOM\Program.cs:line 29
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Inner Exception 1:
HttpRequestException: The SSL connection could not be established, see inner exception.
Inner Exception 2:
IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
Inner Exception 3:
SocketException: An existing connection was forcibly closed by the remote host.
Any help much appreciated :)