You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

POST请求提交大量数据时出现Connection_Reset错误求助

问题:Axios提交大数据POST请求在生产服务器出现Connection_Reset错误

症状

  • 提交1000+行数据的POST请求时,控制台偶尔显示err:Connection_Reset,偶尔出现“This Page can't be displayed”提示
  • 提交10-20行数据时请求正常
  • 已同步测试服务器的PHP配置,问题仍存在

后端代码(Laravel)

public function curlPostRequest(Request $request)
{                   
    $oOutput = Http::withHeaders(['user-username' => \Session::get('username')])->withToken(\Session::get('rrpm_api_acc_token'))->post($this->sApiRoute, $request->all());       
    return response($oOutput, $oOutput->status());
}

前端Axios请求代码

this.axios.post('./rrpm-api/journalVoucher/saveJvDetails', this.third_page_data, config)
    .then(response => {
        this.loading(false);
        if(response.data.code == 0){
            let oldthis = this;
            setTimeout(function(){
                Swal.fire({
                    icon: 'success',
                    text: 'Saved!',
                    showCancelButton: false,
                    allowOutsideClick: false,
                    confirmButtonText: 'ok',
                }).then((result) => {
                    if (result.isConfirmed) {
                        let jv_number = response.data.jv_number;
                        let jv_date = response.data.jv_date;
                        let jv_status = response.data.jv_status;
                        
                        oldthis.directCloseThirdpage('save', jv_number, jv_date, jv_status);
                    }
                })
            }, 100, oldthis);
        }else{
            if(response.data.where){
                setTimeout(function() {
                    Swal.fire({
                        icon: 'error',
                        title: 'Message',
                        text: response.data.where, 
                    })
                }, 100);
            }else{
                setTimeout(function() {
                    Swal.fire({
                        icon: 'error',
                        title: 'Message',
                        text: response.data.message,
                    })
                }, 100);
            }
        }
    })
    .catch(error => {
        if(error.response.data.where){
            setTimeout(function() {
                Swal.fire({
                    icon: 'error',
                    title: 'Message',
                    text: error.response.data.where, 
                })
            }, 100);
        }else{
            setTimeout(function() {
                Swal.fire({
                    icon: 'error',
                    title: error.response.statusText,
                    html: error.response.statusText,
                });
            }, 100);
        }
    });
解决方案
  • 检查Web服务器请求大小限制
    • Nginx:修改nginx.conf或站点配置文件,设置client_max_body_size 50M;(根据实际数据量调整),重启Nginx
    • Apache:确认LimitRequestBody未设置过小,post_max_size已同步测试服务器配置,重启Apache
  • 调整超时时间
    • Laravel Http客户端:在请求中添加超时配置,如->timeout(60)(单位:秒),避免请求因处理时间过长被断开
    • Web服务器:Nginx调整proxy_read_timeout,Apache调整Timeout参数,延长连接超时时间
  • 排查网络层限制
    • 检查生产服务器防火墙、云安全组等设备,确保未限制大请求的大小或连接时长
  • 数据分批提交
    将1000+行数据拆分为多个小批量请求(如每200行一次),降低单请求的数据压力

内容的提问来源于stack exchange,提问作者Vincent Dapiton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 23:54:52