![](/img/trans.png)
[英]Unable to read data from the transport connection: An established connection was aborted by the software in your host machine in C# .Net
[英]Unable to read data from the transport connection: An established connection was aborted by the software in your host machine
我正在使用Webclient類下載網站HTML。 代碼很簡單:
WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
string web = client.DownloadString(url);
但是有時我會收到無法重現的錯誤消息。 它似乎是隨機發生的:
System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
我不知道該錯誤意味着什么或如何解決。 有什么猜想嗎?
首先轉換為NetException(或類似的東西)以跟蹤異常消息。 可能是造成這種情況的多種原因(例如,未支持的方法:)。 如果網絡異常中沒有什么特別的內容,請檢查防火牆或代理。 如果您使用的是代理,請嘗試通過代碼或配置進行設置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.