php - net::ERR_CONNECTION_RESET 当大文件花费超过一分钟时
问题描述
我有一个带有 php 后端的表单中的多部分文件上传。我已经在 php.ini 中设置了 180max_execution_time
并max_input_time
在文件上传时确认这些值TimeOut
在 Apache 中已设置并设置为 180。我也设置了
RewriteRule .* - [E=noabort:1]
RewriteRule .* - [E=noconntimeout:1]
当我在快速连接上上传一个 250MB 的文件时,它工作正常。当我使用较慢的连接或网络链接调节器人为减慢它时,相同的文件会超时,并且 Chrome 会net::ERR_CONNECTION_RESET
在 1 分钟(和 5 秒)后可靠地给我。我还尝试了其他具有相同结果的浏览器,只是错误消息不同。
任何日志中都没有迹象表明有错误,我已经尝试过http
和https
。
什么会导致上传连接在 1 分钟后重置?
编辑
我现在还尝试创建一个简单的上传表单,绕过我正在使用的任何框架,仍然会在 1 分钟后超时。
我还刚刚制作了一个睡眠脚本,该脚本在 2 分半钟后超时,并且有效,页面加载大约需要 2.5 分钟,所以我看不出它与浏览器或标题相关。
我还使用了具有更多 RAM 的服务器来确保它与此无关。我已经在 3 台不同规格的服务器上进行了测试,但都来自同一个 CentOS 7 基础。
我现在也升级到 PHP 7.2 并再次更新了相关字段,问题没有改变。
编辑 2 这个隔离实例的技术堆栈是
- 阿帕奇 2.4.6
- PHP 5.6 / 7.2(都试过了),有 OPCache
- Redis 3.2.6 用于会话信息和键/值存储(ElastiCache)
- PostgreSQL 10.2 (RDS)
我的技术堆栈中的所有其他内容都已从该测试区域中删除,以尝试隔离问题。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},
解决方案
我遇到了类似的问题,在我的情况下,它与mod_reqtimeout相关,添加:
RequestReadTimeout header=20-40, MinRate=500 body=20, MinRate=500
到 httpd.conf 成功了!您可以在此处查看文档。
希望能帮助到你!
推荐阅读
- python - 如何在实时站点上使用 Django 中的 Google 授权应用程序
- python - 使用 TPU 在 GCP 上进行 Keras/Tensorflow 培训
- multithreading - 什么是纺线?
- reactjs - 如何从我的图像助手中获取图像路径不起作用
- mysql - phpmyadmin中列的replce值
- python - 如何从 MATLAB 在 Conda 环境中运行 Python 脚本?
- sqlite - SQLite 选择以比较同一行中的两个最后一个订单
- sql-server - 在 SSIS 中将 VARCHAR 转换为 DATE
- azure - Azure API 管理和 App Function 后端:找不到 ID 为“foo”的后端
- android - 如何使用android studio中的按钮创建一个应用程序来重启/重启android手机?