我一直在使用我用来将图像上传到CloudFlare后面的网站的工具出现问题.此工具首先正常工作,并继续运行,除非请求之间有一个> 1小时的暂停.暂停后,下次连接尝试时会发生异常.
A first chance exception of type 'System.Net.WebException' occurred in System.dll
System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.GetResponse()
Run Code Online (Sandbox Code Playgroud)
我尝试使用调试器来深入研究,但没有InnerException,并且在建立任何连接之前,似乎实际问题源自SChannel.这可以使用以下小程序轻松复制:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Initial connection attempt, this should succeed:");
RunCFRequest();
Console.WriteLine("Wait 70 minutes for next connection attempt...");
Thread.Sleep(70*60*1000);
Console.WriteLine("Second connection attempt, this one should reproduce the failure:");
try
{
RunCFRequest();
}
catch (Exception exc)
{
Console.WriteLine(exc.ToString());
}
Console.WriteLine("Performing another connection attempt after failure to verify we continue working:");
RunCFRequest(); …Run Code Online (Sandbox Code Playgroud)