My app has to download one certain file, here is the url. The app worked fine for years bur after a recent change on provider side I'm getting 'The underlying connection was closed: An unexpected error occurred on a send.'
I have read all related info in net but none of suggested fixes works for me.
Important note: the code works OK with Net Framework 4.6 but I need it to work with 3.5.
Any ideas?
Here is the code:
var url = new Uri(@"http://www.ezv.admin.ch/pdf_linker.php?doc=edecReceiptResponse_stylesheet_v_3_0");
var request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = false;
request.AllowAutoRedirect = true;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
request.ProtocolVersion = HttpVersion.Version10;
update: the stack:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
one more update: checked with Fiddler the app connecting to httpS and compared responses received with net 4.6 (works) with net 3.5 (fails):
- 4.6 receives two responses, 5670 + 664785 bytes
- 3.5 also receives two responses, 7 bytes each