2017-08-09 129 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

相关问题