【发布时间】:2018-03-16 15:43:17
【问题描述】:
我知道到目前为止有几个问题涉及此错误 - 但由于 Azure 上的网络作业,尚未有人生成此错误。
我的代码采用 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方法调用)
如果在我的本地机器上执行它就可以了。如果我将此代码添加到应用服务(ASP.Net Core 项目的一部分)使用的 API 方法中,它也可以工作。
但是,当作为 Azure 网络作业上传时,我收到此错误:
发送请求时出错。
无法连接到远程服务器
试图以一种被其禁止的方式访问套接字 访问权限 xx.xx.xx.xxx:80
关于如何克服这个问题的任何想法?我正在寻找任何可能的解决方案/解决方法。
【问题讨论】:
标签: c# sockets azure azure-webjobs webjob