Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure WebJobs PingException.exe作为控制台应用程序运行良好_C#_Azure - Fatal编程技术网

C# Azure WebJobs PingException.exe作为控制台应用程序运行良好

C# Azure WebJobs PingException.exe作为控制台应用程序运行良好,c#,azure,C#,Azure,我正在尝试构建一个Azure WebJob,以每5分钟检查一个网站的状态。我构建了一个工作正常的控制台应用程序。当它运行时,它将查询MySQL数据库中的网站列表,向该网站提交HTTP请求,然后在MySQL数据库中记录该请求的状态。就像我说的,在控制台上,这一切都很好。当我将其压缩并添加为web作业时,我的程序中运行Ping以获得响应时间的部分失败了。我运行ping的代码是: public ArrayList GetStatusList(ArrayList sites) {

我正在尝试构建一个Azure WebJob,以每5分钟检查一个网站的状态。我构建了一个工作正常的控制台应用程序。当它运行时,它将查询MySQL数据库中的网站列表,向该网站提交HTTP请求,然后在MySQL数据库中记录该请求的状态。就像我说的,在控制台上,这一切都很好。当我将其压缩并添加为web作业时,我的程序中运行Ping以获得响应时间的部分失败了。我运行ping的代码是:

    public ArrayList GetStatusList(ArrayList sites)
    {
        foreach (Website ws in sites)
        {
            HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(ws.WebsiteUrl);
            webRequest.AllowAutoRedirect = false;
            HttpWebResponse response = (HttpWebResponse) webRequest.GetResponse();
            ws.HttpStatus = response.StatusCode.ToString();
            Uri uri = new Uri(ws.WebsiteUrl);
            Ping pingClass = new Ping();
            PingReply pingReply = pingClass.Send(uri.Host);
            ws.ResponseTime = pingReply.RoundtripTime;
            ws.WebsiteCheckedDateTime = DateTime.Now;
        }
下面是Azure WebJob中的错误日志:

[02/01/2016 19:33:37 > c91ef2: SYS INFO] Status changed to Stopped
[02/01/2016 19:33:57 > c91ef2: SYS INFO] Detected WebJob file/s were updated, refreshing WebJob
[02/01/2016 19:33:57 > c91ef2: SYS INFO] Status changed to Starting
[02/01/2016 19:33:57 > c91ef2: SYS WARN] 'Always On' doesn't appear to be enabled for this Web App. To ensure your continuous job doesn't stop running when the SCM host is idle for too long, consider enabling 'Always On' in the configuration settings for your Web App. Note: 'Always On' is available only in Basic, Standard and Premium modes.
[02/01/2016 19:33:57 > c91ef2: SYS INFO] Run script 'IsItAlive.exe' with script host - 'WindowsScriptHost'
[02/01/2016 19:33:57 > c91ef2: SYS INFO] Status changed to Running
[02/01/2016 19:33:58 > c91ef2: INFO] Connected to DB, MySQL version : 5.5.45-log
[02/01/2016 19:33:58 > c91ef2: ERR ] 
[02/01/2016 19:33:58 > c91ef2: ERR ] Unhandled Exception: System.Net.NetworkInformation.PingException: An exception occurred during a Ping request. ---> System.ComponentModel.Win32Exception: There are no more endpoints available from the endpoint mapper
[02/01/2016 19:33:58 > c91ef2: ERR ]    at System.Net.NetworkInformation.Ping.InternalSend(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options, Boolean async)
[02/01/2016 19:33:58 > c91ef2: ERR ]    at System.Net.NetworkInformation.Ping.Send(IPAddress address, Int32 timeout, Byte[] buffer, PingOptions options)
[02/01/2016 19:33:58 > c91ef2: ERR ]    --- End of inner exception stack trace ---
[02/01/2016 19:33:58 > c91ef2: ERR ]    at System.Net.NetworkInformation.Ping.Send(IPAddress address, Int32 timeout, Byte[] buffer, PingOptions options)
[02/01/2016 19:33:58 > c91ef2: ERR ]    at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
[02/01/2016 19:33:58 > c91ef2: ERR ]    at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress)
[02/01/2016 19:33:58 > c91ef2: ERR ]    at IsItAlive.BusinessLogic.GetStatusOfSites.GetStatusList(ArrayList sites)
[02/01/2016 19:33:58 > c91ef2: ERR ]    at IsItAlive.Program.Main(String[] args)
[02/01/2016 19:33:58 > c91ef2: SYS ERR ] Job failed due to exit code -532462766
[02/01/2016 19:33:58 > c91ef2: SYS INFO] Process went down, waiting for 60 seconds
[02/01/2016 19:33:58 > c91ef2: SYS INFO] Status changed to PendingRestart
我确信答案就在眼前,但我只是没有足够的经验来理解错误日志。有人能帮我理解为什么我的Ping在作为WebJob而不是控制台应用程序运行时会导致Ping异常吗

---> System.ComponentModel.Win32Exception: There are no more endpoints available from the endpoint mapper
从这一行的外观来看,您的应用程序正在访问计算机上存在但Azure Web App Worker上不可用的内容,或者是Worker上运行的沙箱的受限调用

你可以查看更多关于这个项目的信息

在上面链接的页面上,可能导致错误的限制之一是

网络限制/注意事项

在网络访问方面,存在多种限制 Azure Web应用程序。本节概述特定于Azure应用程序的限制 服务此外,应用程序仍受Azure自身的限制 网络限制

网络端点侦听

通过internet访问应用程序的唯一方法是 通过已经公开的HTTP(80)和HTTPS(443)TCP端口; 应用程序可能无法在其他端口上侦听来自的数据包 互联网。但是,应用程序可能会创建一个套接字,该套接字可以 从沙盒中侦听连接。例如,两个 同一应用程序中的进程可以通过TCP相互通信 插座;从沙箱外部传入的连接尝试,尽管 它们在同一台机器上,将失败。有关详细信息,请参见下一主题 其他细节


好吧,这很糟糕,但也解释了为什么ping不起作用。谢谢。也有类似的问题。在本地一切正常,但在azure上失败。所有请求/响应都使用80/443端口发送。奇怪的