10054: An existing connection was forcibly closed by the remote host
2017-08-09 16:09
1696 查看
现象打开页面,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代码的问题。
通过排除法,确定是下面红色的代码导致:
常量BEYOND_WIDGET定义如下:
另外,这个问题在PHP 7下是没有的,在PHP 5.6下出现。
简单总结一下,就是在PHP 5.6下,条件语句中访问常量数组会出问题(未有全面测试,仅从本案例得到结论,不一定准确)。
解决既然常量不行,那就把常量改成变量:
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 { } |
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 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 { } |
相关文章推荐
- 当WCF遭遇An existing connection was forcibly closed by the remote host
- An existing connection was forcibly closed by the remote host
- An existing connection was forcibly closed by the remote host
- .Net Remoting 排错笔记:An existing connection was forcibly closed by the remote host
- django an established connection was aborted by the software in you host machine
- An established connection was aborted by the software in your host machine
- 【转载】 ssh_exchange_identification: Connection closed by remote host
- ssh问题:ssh_exchange_identification: Connection closed by remote host...
- ssh问题:ssh_exchange_identification: Connection closed by remote host
- No operations allowed after connection closed.Connection was implicitly closed by the driver
- SSH连接服务器报ssh_exchange_identification: Connection closed by remote host
- 使用xshell连接服务器问题:ssh_exchange_identification: Connection closed by remote host
- 【Ansible】SSH Error: ssh_exchange_identification: Connection closed by remote host
- ssh_exchange_identification: Connection closed by remote host
- ssh问题:ssh_exchange_identification: Connection closed by remote host
- ssh_exchange_identification: Connection closed by remote host 问题的解决 (转)
- The remote host closed the connection. The error code is 0x80072746.
- ssh_exchange_identification: Connection closed by remote host