如何编写脚本如果收到通信错误,默认情况下,功能应重试最多3次,重试间隔15秒。是否执行通信错误重试,重试次数和尝试之间的等待间隔应为客户端可配置参数。请帮帮我。
答案 0 :(得分:1)
您只需添加FailedCounts
之类的变量即可使用。
类似的东西:
var failedCounts = 0, myInterval;
myInterval = setInterval(function() {
if (operationFailed) {
failedCounts++;
if (failedCounts >= 3) {
clearInterval(myInterval); // probably, you may want to disable timer on failure
alert('Failed 3 times');
}
} else {
failedCount = 0;
}
}, 15000);