首页 > 解决方案 > net::ERR_CONNECTION_RESET 当大文件花费超过一分钟时

问题描述

我有一个带有 php 后端的表单中的多部分文件上传。我已经在 php.ini 中设置了 180max_execution_timemax_input_time在文件上传时确认这些值TimeOut在 Apache 中已设置并设置为 180。我也设置了

RewriteRule .* - [E=noabort:1]
RewriteRule .* - [E=noconntimeout:1]

当我在快速连接上上传一个 250MB 的文件时,它工作正常。当我使用较慢的连接或网络链接调节器人为减慢它时,相同的文件会超时,并且 Chrome 会net::ERR_CONNECTION_RESET在 1 分钟(和 5 秒)后可靠地给我。我还尝试了其他具有相同结果的浏览器,只是错误消息不同。

任何日志中都没有迹象表明有错误,我已经尝试过httphttps

什么会导致上传连接在 1 分钟后重置?

编辑

我现在还尝试创建一个简单的上传表单,绕过我正在使用的任何框架,仍然会在 1 分钟后超时。

我还刚刚制作了一个睡眠脚本,该脚本在 2 分半钟后超时,并且有效,页面加载大约需要 2.5 分钟,所以我看不出它与浏览器或标题相关。

我还使用了具有更多 RAM 的服务器来确保它与此无关。我已经在 3 台不同规格的服务器上进行了测试,但都来自同一个 CentOS 7 基础。

我现在也升级到 PHP 7.2 并再次更新了相关字段,问题没有改变。

编辑 2 这个隔离实例的技术堆栈是

我的技术堆栈中的所有其他内容都已从该测试区域中删除,以尝试隔离问题。EFS 在系统上,但在我最孤立的测试中,它只是使用 EBS。

编辑 3 这里有一些来自 chrome 网络调试器的日志:

{"params":{"net_error":-101,"os_error":32},"phase":0,"source":    {"id":274043,"type":8},"time":"3332701830","type":69},
{"params":    {"error_lib":33,"error_reason":101,"file":"../../net/socket/socket_bio_adapter.cc","line":216,"net_error":-101,"ssl_error":1},"phase":0,"source":        {"id":274043,"type":8},"time":"3332701830","type":56},
{"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":159},
{"phase":1,"source":    {"id":274038,"type":1},"time":"3332701830","type":164},
{"phase":1,"source":    {"id":274038,"type":1},"time":"3332701830","type":287},
{"params":    {"error_lib":33,"error_reason":101,"file":"../../net/socket/socket_bio_adapter.cc","line":113,"net_error":-101,"ssl_error":1},"phase":0,"source":    {"id":274043,"type":8},"time":"3332701830","type":55},
{"params":{"net_error":-101},"phase":2,"source":    {"id":274038,"type":1},"time":"3332701830","type":287},
{"params":{"net_error":-101},"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":164},
{"params":{"net_error":-101},"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":97},
{"phase":1,"source":{"id":274038,"type":1},"time":"3332701830","type":105},
{"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":105},
{"phase":2,"source":{"id":274043,"type":8},"time":"3332701830","type":38},
{"phase":2,"source":{"id":274043,"type":8},"time":"3332701830","type":38},
{"phase":2,"source":{"id":274043,"type":8},"time":"3332701830","type":34},
{"params":{"net_error":-101},"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":2},

标签: phpapachefile-upload

解决方案


我遇到了类似的问题,在我的情况下,它与mod_reqtimeout相关,添加:

RequestReadTimeout header=20-40, MinRate=500 body=20, MinRate=500

到 httpd.conf 成功了!您可以在此处查看文档。

希望能帮助到你!


推荐阅读