花费太长时间重试连接 [英] Retry connection when it takes too long

查看:95
本文介绍了花费太长时间重试连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当通话在待处理状态停留超过几秒钟时,是否可以在Angular中重试连接?

Is it possible in Angular to retry a connection when the calls stays for more then a couple of seconds on pending?

推荐答案

应该与 pipe timeout retry 组合使用来自Rxjs.如果超过了 timeout ,则 retry 4次,否则为 catchError .

Should be doable with a combination of pipe, timeout and retry from Rxjs. If timeout is exceeded, retry 4 times, else, catchError.

return this.httpClient.post(url, data, httpOptions).pipe(
  timeout(3000),
  retry(4),
  catchError(<DO SOMETHING>)
);

这篇关于花费太长时间重试连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆