gpt4 book ai didi

c# - Azure WebJob 命令超时

转载 作者:可可西里 更新时间:2023-11-01 07:54:45 28 4
gpt4 key购买 nike

我们在使用 Azure Web 作业时遇到问题。我们创建了一个 C# 控制台应用程序,将其压缩,然后创建了新的 Web 作业。这是一个 C# 控制台应用程序,它将不断访问我们的一个 Web 服务来处理队列中的项目。

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

'cmd /c xxxxxxxx....' aborted due to no output and CPU activity for 121 seconds. You may increase SCM_COMMAND_IDLE_TIMEOUT setting to solve the issue

当我们将 SCM_COMMAND_IDLE_TIMEOUT 增加到 600(10 分钟)时。该作业运行了 10 分钟 - 然后我们得到了相同的错误和相同的 121 秒 错误。

我们做错了什么?

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

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

关于c# - Azure WebJob 命令超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25489467/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com