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

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

问题描述

当呼叫在挂起时停留超过几秒钟时,Angular 是否可以重试连接?

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

推荐答案

应该可以结合 pipetimeoutretry来自 Rxjs.如果超过timeoutretry 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天全站免登陆