我知道目前为止有几个问题涉及此错误 - 但是由于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
如何突破这个任何想法?我正在寻找任何可能的解决方案/解决方法。
能否请您澄清 - 如何将一个解决这个问题?有没有方法可以改变传出连接限制,或者可以将可以建立连接的IP地址列入白名单? – NoReceipt4Panda