http - Ballerina:在启动入站响应之前触发空闲超时
问题描述
我在每 10 分钟运行一次的芭蕾舞演员项目中执行任务预约。它可以正常工作大约一个小时,但是当执行时间达到 2 小时时,它会给我一个错误。以下是错误日志。
2018-10-04 12:00:00,002 INFO - Scanning the Github repository
2018-10-04 12:01:00,008 ERROR - Idle timeout triggered before initiating inbound response : {message:"Idle timeout triggered before initiating inbound response", cause:null, statusCode:0}
从错误日志来看,空闲时间似乎是 1 分钟。
这是程序代码。
public function main(string... args) {
log:printInfo("------ Scheduling Appointments --------------");
(function() returns error?) onTriggerFunction = gitHubTaskExecute;
(function(error)) onErrorFunction = gitGubTaskError;
gitGubTask = new task:Appointment(onTriggerFunction,
onErrorFunction,
"0 30 1 * * ?");
gitGubTask.schedule();
}
}
@Description { value:"Execute the Github repository scanning task"}
function gitHubTaskExecute() returns (error?) {
log:printInfo("Scanning the Github repository : " + repository);
executedTaskCount = executedTaskCount + 1;
if (executedTaskCount == 100) {
log:printInfo("Stopping Appointment#1 cleanup task since it
has run 100 times");
gitGubTask.cancel();
}
return cleanup();
}
@Description { value:"Execute the task cleanup"}
function cleanup() returns (error?) {
//Call function here
return ();
}
知道是什么触发了这个错误吗?我想实现一个应该每天执行的任务。
解决方案
请注意,当连接空闲超过指定时间段时,IdleTimeout 会触发。然后服务器/客户端会以适当的响应关闭连接。>= 0
如果您想禁用它,您可以将其设置为。
示例客户端端点:
endpoint http:Client clientEndpoint {
url: "http://localhost:9090",
timeoutMillis: 300000
};
timeoutInMillis
在 http 客户端和服务器端点中调用了一个配置。如果需要,您可以增加此值。