[英]SocketException 16010 on GET/POST to https from local WCF service
我正在編寫本地C#WCF服務。 我可以正常工作,除了需要與https api交互的地方。 每當我嘗試獲取/發布到https時,我都會得到一個socketexception(16010)(可以與http調用正常工作)
例:
private async void test()
{
var client = new System.Net.Http.HttpClient();
//The next line works just fine, I get a response back
var r = await client.GetAsync("http://www.google.com/appsstatus/rss/en");
HttpContent responseContent = r.Content;
//SOCKETEXCEPTION 16010 at next line
var r2 = await client.GetAsync("https://www.google.com/appsstatus/rss/en");
HttpContent responseContent2 = r2.Content;
}
當我通過Visual Studio調試器(iis express)運行我的服務時,以及在我的憑據上運行有應用程序池的本地完整IIS服務器上托管該服務時,都會發生這種情況。
我不確定如何開始追逐這一步。 任何指針將不勝感激。
異常詳細信息:
System.Net.Sockets.SocketException occurred
Message: A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
Additional information: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
使用服務棧
var a = "https://www.google.com/appsstatus/rss/en".GetXmlFromUrl();
我得到以下內容:
System.Net.Sockets.SocketException occurred
_HResult=-2147467259
_message=A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
HResult=-2147467259
IsTransient=false
Message=A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 23.21.209.160:443
Source=System
ErrorCode=10060
NativeErrorCode=10060
StackTrace:
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
InnerException:
您確定您的第一個電話不是正在處理或更改client
對象的狀態嗎? 你有嘗試過嗎?
var client = new System.Net.Http.HttpClient();
//The next line works just fine, I get a response back
var r = await client.GetAsync("http://www.google.com/appsstatus/rss/en");
HttpContent responseContent = r.Content;
//SOCKETEXCEPTION 16010 at next line
client = new System.Net.Http.HttpClient();
var r2 = await client.GetAsync("https://www.google.com/appsstatus/rss/en");
HttpContent responseContent2 = r2.Content;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.