2017-08-09 31 views
0

我知道目前爲止有幾個問題涉及此錯誤 - 但是由於Azure上的webjob,沒有人生成此錯誤。Azure Webjob:嘗試以訪問權限禁止的方式訪問套接字xxxx:80

我的代碼是C#Console Application的形式。我的代碼的主要部分:

HttpClient client = new HttpClient(); 
var byteArray = Encoding.ASCII.GetBytes("user:password"); 
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray)); 
HttpResponseMessage response = await client.GetAsync("http://xx.xx.xx.xxx/cgi-bin/snapshot.cgi?channel=0"); 
byte[] myBytes = await response.Content.ReadAsByteArrayAsync(); 
string convertedFromString = Convert.ToBase64String(myBytes); 

如果我的本地機器上執行(上面的代碼是由Main方法調用)

它工作得很好。如果我將這些代碼添加到App Service使用的API方法(ASP.Net Core項目的一部分)中,它也可以使用。

然而,當作爲Azure的webjob上傳,我得到這個錯誤:

An error occurred while sending the request.

Unable to connect to the remote server

An attempt was made to access a socket in a way forbidden by its access permissions xx.xx.xx.xxx:80

如何突破這個任何想法?我正在尋找任何可能的解決方案/解決方法。

回答

1

An attempt was made to access a socket in a way forbidden by its access permissions xx.xx.xx.xxx:80

根據我的理解,我認爲你可能會遇到來自Azure Web App sandbox的傳出連接限制。另外,我建議您可以將您的應用託管計劃擴展到較大的實例以縮小此問題。

另外,這裏有一些類似的問題,你可以參考他們:

Intermittent crashes in Azure Web Application

Starving outgoing connections on Windows Azure Web Sites

+0

能否請您澄清 - 如何將一個解決這個問題?有沒有方法可以改變傳出連接限制,或者可以將可以建立連接的IP地址列入白名單? – NoReceipt4Panda

相關問題