Azure WebJob命令超时 [英] Azure WebJob Command Timeout
问题描述
我们在使用Azure Web作业时遇到问题.我们创建了一个C#控制台应用程序,将其压缩并创建了新的Web Job.这是一个c#控制台应用程序,它将不断访问我们的一个Web服务来处理队列中的项目.
We are having issue with Azure Web Jobs. We created a C# console application, zipped it, and created the new Web Job. It's a c# console app that will constantly hit one of our web services to process items in queue.
每当我们运行Web Job时,都会出现以下错误:
Whenever we run the Web Job, we are getting the following error:
'cmd/c xxxxxxxx ....'因无输出和CPU活动而中止 121秒您可以将SCM_COMMAND_IDLE_TIMEOUT设置增加到 解决问题
'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 seconds
错误.
When we increased the SCM_COMMAND_IDLE_TIMEOUT to 600
(10 minutes). The job DOES run for 10 minutes - and then we get the same error with the same 121 seconds
error.
我们在做什么错?
这是控制台应用程序代码:
Here is the console app code:
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++;
}
}
我们是否以错误的方式来解决这个问题?
Are we approaching this problem the wrong way?
注意:每个HttpHelper.HttpPOST
请求大约需要2秒钟-这不是问题.
Note: each HttpHelper.HttpPOST
request takes about 2 seconds - so that's not the issue.
注2:我们正在使用Task.Run
来创建设置并忘记设置"类型的请求.
Note2: We are using Task.Run
to create "set-it-and-forget-it" type of requests.
注意3:网站设置始终在线"已打开.
Note3: The website setting of "Always On" - is turned on.
推荐答案
这似乎已经解决了我的问题:
This seems to have solved my problem:
if (Counter % 25 == 0)
Console.WriteLine("Heartbeat");
我想您必须继续写到控制台以保持JOB的运行.
I guess you have to keep writing out to console to keep the JOB running.
这篇关于Azure WebJob命令超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!