Azure WebJob命令超时

我们遇到Azure Web Jobs问题。 我们创建了一个C#控制台应用程序,压缩它,并创建了新的Web作业。 这是一个ac#console应用程序,它将不断点击我们的一个Web服务来处理队列中的项目。

每当我们运行Web作业时,我们都会收到以下错误:

‘cmd / c xxxxxxxx ….’由于没有输出和CPU活动而中止了121秒。 您可以增加SCM_COMMAND_IDLE_TIMEOUT设置以解决问题

当我们将SCM_COMMAND_IDLE_TIMEOUT增加到600 (10分钟)时。 作业运行10分钟 – 然后我们得到相同的错误,同样的121 seconds错误。

我们做错了什么?

这是控制台应用程序代码:

 static void Main(string[] args) { bool ThereAreItemsInQueue = true; int Counter = 1; DateTime StartTime = DateTime.Now; while(ThereAreItemsInQueue) { Task.Run(() => { try { //DEQUEUE byte[] response = HttpHelper.HttpPOST(@"xxxxxxxxxxxxx", new byte[0]); string strResponse = System.Text.Encoding.Default.GetString(response); System.Diagnostics.Trace.TraceError("Attempt #" + Counter + "DEQUEUE FINISHED. Response:" + strResponse); //CHECK IF THE QUEUE IS EMPTY if (strResponse.Contains("Were Done")) ThereAreItemsInQueue = false; } catch(Exception ex) { System.Diagnostics.Trace.TraceError("Error Has Occured on attempt #" + Counter + "." + ex.Message + "\r" + ex.StackTrace); } }); System.Threading.Thread.Sleep(5000); //SEE IF THIS HAS BEEN RUNNING FOR MORE THAN 24 HOURS if (DateTime.Now.Subtract(StartTime).TotalHours >= 24) ThereAreItemsInQueue = false; Counter++; } } 

我们是以错误的方式处理这个问题吗?

注意:每个HttpHelper.HttpPOST请求大约需要2秒 – 所以这不是问题。

注意2:我们使用Task.Run创建“set-it-and-forget-it”类型的请求。

注3:“Always On”的网站设置 – 已打开。

对于触发的WebJobs,增加空闲超时的方法是使用应用程序设置: WEBJOBS_IDLE_TIMEOUT 。 将其设置为所需的超时秒数。

该错误令人困惑,仅指部署期间的空闲超时。

https://github.com/projectkudu/kudu/wiki/Web-jobs#configuration-settings

这似乎解决了我的问题:

 if (Counter % 25 == 0) Console.WriteLine("Heartbeat"); 

我想你必须继续写出控制台以保持JOB运行。