Httpclient角度发布请求如果失败,然后在数据库中插入多个条目

问题描述

从角度发出请求时,端点“ ERR_CONNECTION_RESET”发生错误,然后可能是正在重试并在db中插入重复记录。

我正在这样发送角度的帖子请求。

public post(url: string,request: any): any {
    return this.httpClient.post(environment.emp_api_endpoint + url,request,this.options);
}

我已经验证了来自邮递员的相同呼叫,它工作正常并且仅插入记录一次。

我已经尝试过下面的代码,但是它也不起作用。

public postWithnoretry(url: string,this.options)
    .pipe(
        retry(0)
      );
}

请建议我,如何在失败/超时/重置后停止呼叫而不重试。

我已对此问题net::ERR_CONNECTION_RESET angular api request causes duplicates?添加评论,看起来与我的问题相似。但是没有得到令人满意的答案。

已更新

uploadCustomSignByExcel(data: any): Observable<ServiceResponse<boolean>> {
    return this.apiService.post(String.Format(SignsConstants.API.CustomUploadExcelSign,this._offer.Id),data);
}

  uploadCustomSigns() {
    const formData = new FormData();
    formData.append(this.file.name,this.file,this.file.name);
    const requestId = this.NewGuid();
    formData.append('RequestId',requestId);
    formData.append('CsdCodes',requestId);
    this.uploadCustomSignByExcel(formData).subscribe(data => {
      if (data.IsSuccess) {
        // this.eventService.getExcelUploadStatus(requestId,this.uploadProductsCallBack);
      } else {
        console.log(data.ErrorMessages[0]);
      }
      this.file = null;
      this.filename = 'browse...';
    },_ => {
      this.file = null;
      this.filename = 'browse...';
    });
  }

然后点击按钮调用uploadCustomSigns。

更新2

API sending ERR_CONNECTION_RESET error in 2.1 mins,but client is making autoretry in 61 seconds

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...