recv() failed (104: Connection reset by peer) while reading response header from upstream
2017-09-30 00:00
316 查看
今天同事一段代码在本地开发环境运行正常,发到测试服务器却总是报 502 。
这段代码是在一个循环中调用了一个第三方api
于是我首先想到超时,但是观察后发现也就几秒钟就报错了,然后 ini_get("max_execution_time") 结果是30 没问题。
于是又想到内存问题,但是 API 请求回来的数据不多 内存超限的可能性不大。
然后就只能去服务器看 nginx 日志了,于是找到下面的错误信息:
[error] 19063#0: *2450550 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 222.41.170.174, server: xxx.com, request: "GET /index/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.com"
意思大概是 "fastcgi://127.0.0.1:9000" 断开了与 nginx 的连接。
这样就很明显了 应该是 fpm 的问题,而且应该是超时之类的问题,而且很可能是配置的问题,因为 php 代码本身应该是没有问题的。
打开 php-fpm.conf 发现了:request_terminate_timeout = 5
估计就是这儿了 ,改成 30 ,果然 问题解决!
-----------------------------------------------------------
request_terminate_timeout :
表示每个到fastcgi的请求的超时时间,它的设计目的是为 在 php.ini 中的max_execution_time设置在某些特殊原因下不能终止 PHP 执行的情况。
于是,request_terminate_timeout 也就默默的成为限制 PHP 执行时间的另一个手段。
而request_terminate_timeout 和 max_execution_time 在一般情况下的关系是:
哪个值小,哪个起作用。。。
这段代码是在一个循环中调用了一个第三方api
于是我首先想到超时,但是观察后发现也就几秒钟就报错了,然后 ini_get("max_execution_time") 结果是30 没问题。
于是又想到内存问题,但是 API 请求回来的数据不多 内存超限的可能性不大。
然后就只能去服务器看 nginx 日志了,于是找到下面的错误信息:
[error] 19063#0: *2450550 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 222.41.170.174, server: xxx.com, request: "GET /index/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.com"
意思大概是 "fastcgi://127.0.0.1:9000" 断开了与 nginx 的连接。
这样就很明显了 应该是 fpm 的问题,而且应该是超时之类的问题,而且很可能是配置的问题,因为 php 代码本身应该是没有问题的。
打开 php-fpm.conf 发现了:request_terminate_timeout = 5
估计就是这儿了 ,改成 30 ,果然 问题解决!
-----------------------------------------------------------
request_terminate_timeout :
表示每个到fastcgi的请求的超时时间,它的设计目的是为 在 php.ini 中的max_execution_time设置在某些特殊原因下不能终止 PHP 执行的情况。
于是,request_terminate_timeout 也就默默的成为限制 PHP 执行时间的另一个手段。
而request_terminate_timeout 和 max_execution_time 在一般情况下的关系是:
哪个值小,哪个起作用。。。
相关文章推荐
- recv() failed (104: Connection reset by peer) while reading response header from upstream
- php502问题解决:recv() failed (104: Connection reset by peer) while reading response header from upstream
- recv() failed (104: Connection reset by peer) while reading response header from upstream
- recv() failed (104: Connection reset by peer) while reading response header from upstream
- 解决 recv() failed (104: Connection reset by peer) while reading response header from upstream
- failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x
- nginx 8051#0: *4 recv() failed (104: Connection reset by peer) while reading response header from u
- nginx recv() failed (104: Connection reset by peer) while reading response header from upstream解决方法
- 对于PHP引起的(104: Connection reset by peer) while reading response header from upstream错误解决方法
- nginx [error] 15644#0: *112680 recv() failed (104: Connection reset by peer) while reading response
- java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- get value from agent failed: ZBX_TCP_READ() failed;[104] connection reset by peer
- django upstream prematurely closed connection while reading response header from up
- java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)我的解决办法
- upstream prematurely closed connection while reading response header from upstream分析与解决
- 迷糊的IOException:Java.NET.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
- nginx 502 日志 . recv() failed (104: Connection reset by peer)报错
- upstream timed out (110: Connection timed out) while reading response header from upstream 问题解决