recv() failed (104: Connection reset by peer) while reading response header from upstream
Posted 土木系师兄
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了recv() failed (104: Connection reset by peer) while reading response header from upstream相关的知识,希望对你有一定的参考价值。
场景: 为了得到用户在线等信息,在客户端做了个ajax轮训; 于是问题就来了, 日志文件 [[email protected] web]# tail -f /data/log/nginx_error.log 2017/06/16 19:20:28 [error] 230555#0: *10228041 recv() failed (104: Connection reset by peer)
while reading response header from upstream,client: 42.19.1.114, server: 47.18.212.1, request:
"POST /api-chat/subshade?rnd=880 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000",
host: "www.1j008.com", referrer: "http://www.2008.com/6166" .......狂刷此错误 [[email protected] web]# tail -f /data/log/php-fpm.log [19-Jun-2017 10:51:05] WARNING: [pool www] child 754153 exited on signal 11 (SIGSEGV) after 74.433547 seconds from start [19-Jun-2017 10:51:05] NOTICE: [pool www] child 755405 started .......狂刷此错误 百度谷歌后分析结果: 大意是说 1. php程序执行时间超过 php-fpm.conf 中 request_terminate_timeout = 300;设置的值,然后php-fpm进程退出,此时nginx得不到php-fpm进程的正确结果 解决方法: 改request_terminate_timeout 0;不限制超时 2. php-fpm进程数量来不及处理。 解决方法: 改 php-fpm进程数 3. 因为每个php-fpm在处理一定数量请求后自动stop,然后create new php-fpm 解决方法: 改pm.max_requests限制 ..... 对应一下我的日志看来,网上的症状确实与我的同出一辙。 对应着改了一轮下来问题依旧、 好;既然无果那么我分析一下php-fpm疯狂的终止原因 [[email protected] web]#dmesg ...... php-fpm[744779]: segfault at 1c ip 00000000007a8ea1 sp 00007ffe40af5330 error 4 in php-fpm[400000+9a9000] php-fpm[744924]: segfault at 10bc890 ip 000000000078931f sp 00007ffe40af56e8 error 4 in php-fpm[400000+9a9000] php-fpm[746677]: segfault at 1c ip 00000000007a8ea1 sp 00007ffe40af5330 error 4 in php-fpm[400000+9a9000] php-fpm[746738]: segfault at 0 ip 00000000007a8ead sp 00007ffe40af5330 error 6 in php-fpm[400000+9a9000] php-fpm[746371] general protection ip:7a8ead sp:7ffe40af5330 error:0 in php-fpm[400000+9a9000] 好了,问题找到 在php里面我确实处理过客户端ip 类似$_SERVER[‘REMOVE_ADDR‘]方法得到的ip 经过ip2long ( string $ip_address )转换时出错, 因为 $ip_address = "这里的ip不合符规则里面有逗号" 过滤之.... 安静了
以上是关于recv() failed (104: Connection reset by peer) while reading response header from upstream的主要内容,如果未能解决你的问题,请参考以下文章
[error] 2340#0: *3571 recv() failed (104: Connection reset by peer) while reading response header fr
[error] 2340#0: *3571 recv() failed (104: Connection reset by peer) while reading response header fr
反向代理 27833 recv() failed (104: Connection reset by peer) while reading response header from upstream