10054: An existing connection was forcibly closed by the remote host

简介:
现象

打开页面,PHP-CGI退出,Nginx错误日志如下:

2017/08/09 15:13:31 [error] 8140#19268: *1 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /siteManager/template/templateEdit.html?id=1 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9090", host: "localhost:8202", referrer: http://localhost:8202/siteManager/template/templateList.html

原因

打开其它页面都没问题,只有这个页面有问题,应该是那个页面的PHP代码的问题。

通过排除法,确定是下面红色的代码导致:

if ($name == self::INPUT_HIDDEN) {            
elseif($name == self::INPUT_LARGE_FILE_UPLOAD) {            
elseif (isset(self::BEYOND_WIDGET[$name])) {            
elseif ($name == self::INPUT_RICH_EDIT) {            
else {            
}

常量BEYOND_WIDGET定义如下:

const INPUT_JSON = 'jsonEditor';            
const INPUT_RICH_EDIT = 'richEdit';            
const INPUT_HTML_CODE_EDITOR = 'htmlCodeEditor';            
const BEYOND_WIDGET = [            
self::INPUT_JSON => 'common\widgets\jsonEditor\JsonEditor',            
self::INPUT_IMAGE => 'common\widgets\inputImage\InputImage',            
self::INPUT_HTML_CODE_EDITOR => 'common\widgets\htmlCodeEditor\HtmlCodeEditor',            
];

另外,这个问题在PHP 7下是没有的,在PHP 5.6下出现。

简单总结一下,就是在PHP 5.6下,条件语句中访问常量数组会出问题(未有全面测试,仅从本案例得到结论,不一定准确)。

解决

既然常量不行,那就把常量改成变量:

const INPUT_JSON = 'jsonEditor';            
const INPUT_RICH_EDIT = 'richEdit';            
const INPUT_HTML_CODE_EDITOR = 'htmlCodeEditor';            
private $BEYOND_WIDGET = [              
self::INPUT_JSON => 'common\widgets\jsonEditor\JsonEditor',              
self::INPUT_IMAGE => 'common\widgets\inputImage\InputImage',              
self::INPUT_HTML_CODE_EDITOR => 'common\widgets\htmlCodeEditor\HtmlCodeEditor',              
];

if ($name == self::INPUT_HIDDEN) {            
elseif($name == self::INPUT_LARGE_FILE_UPLOAD) {            
elseif (isset($this->BEYOND_WIDGET[$name])) {            
elseif ($name == self::INPUT_RICH_EDIT) {            
else {            
}






本文转自 tywali 51CTO博客,原文链接:http://blog.51cto.com/lancelot/1954846,如需转载请自行联系原作者

目录
相关文章
|
3月前
|
Go 开发工具 git
【git】解决:Failed to connect to 127.0.0.1 port 7890: Connection refused
【git】解决:Failed to connect to 127.0.0.1 port 7890: Connection refused
511 0
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
161 0
|
Linux
七个办法只有一个有效:200 PORT command successful. Consider using PASV.425 Failed to establish connection.
七个办法只有一个有效:200 PORT command successful. Consider using PASV.425 Failed to establish connection.
416 0
七个办法只有一个有效:200 PORT command successful. Consider using PASV.425 Failed to establish connection.
执行HQL直接被退出:Remote side unexpectedly closed network connection
执行HQL直接被退出:Remote side unexpectedly closed network connection
1064 0
执行HQL直接被退出:Remote side unexpectedly closed network connection
|
网络安全 开发工具 git
git schnnel failed to receive handshake, SSLTLS connection failed
git schnnel failed to receive handshake, SSLTLS connection failed
216 0
|
Java 应用服务中间件 数据库
Connection reset by peer
部署项目时A服务启动失败,报错: 14-Aug-2019 12:52:49.860 SEVERE [main] org.springframework.web.context.ContextLoader.
11283 0
|
应用服务中间件 nginx
[error] 17755#0: *58522 readv() failed (104: Connection reset by peer) while reading upstream
[error] 17755#0: *58522 readv() failed (104: Connection reset by peer) while reading upstream
4906 0
|
Web App开发 监控 应用服务中间件
recv() failed (104: Connection reset by peer) while reading response header from upstream
2017年12月1日10:18:34 情景描述: 浏览器执行了一会儿, 报500错误 运行环境:  nginx + php-fpm nginx日志:  recv() failed (104: Connection reset by peer) while reading response he...
9191 0

热门文章

最新文章