I get that exception when I try download string using WebClient. I tried many cases to setup ServicePointManager: ServicePointManager.Expect100Continue: true and false ServicePointManager.SecurityProtocol: SecurityProtocolType.Ssl3 and SecurityProtocolType.Tls12 and (SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12) and all Tls and all protocols. Every combination was used. Not working
CallStack: Failed to get fixtures from URI=https://myurl/2019-05-29. System.Net.WebException: An exception occurred during a WebClient request. ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream. at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.WebClient.DownloadBitsState.RetrieveBytes(Int32& bytesRetrieved) at System.Net.WebClient.DownloadBits(WebRequest request, Stream writeStream, CompletionDelegate completionDelegate, AsyncOperation asyncOp) at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) --- End of inner exception stack trace --- at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at System.Net.WebClient.DownloadString(String address)
Code with one case:
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
using (var wc = new WebClient())
{
try
{
var json = wc.DownloadString(uri);
}
catch (Exception e)
{
return null;
}
}
Aucun commentaire:
Enregistrer un commentaire