Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of UCenter Communication failure under Nginx

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to solve the problem of UCenter communication failure under Nginx. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Solve the problem of UCenter communication failure under Nginx. Phenomenon

In the end, the communication failed, but the code that tracks ucenter has the following code in the dfopen () function of uc_server/model/misc.php:

If (! $fp = @ fsocketopen (($scheme = = 'https'? 'ssl': $scheme).': / /'. ($scheme = = 'https'? $host: ($ip? $ip: $host)), $port, $errno, $errstr, $timeout) {

$context = array (

'http' = > array (

'method' = > $post? 'POST': 'GET'

'header' = > $header

'content' = > $post

'timeout' = > $timeout

),

);

$context = stream_context_create ($context)

$fp = @ fopen ($scheme.'://'. ($scheme = = 'https'? $host: ($ip? $ip: $host)).':. $port.$path, 'baked, false, $context)

Set a breakpoint within the if condition, that is, when the call to the fsocketopen () function fails, look at the contents of the $errstr variable, whose value is as follows:

Unable to find the socket transport "http"-did you forget to enable it when you configured PHP?

Reason

Look at the code for the fsocketopen function:

Function fsocketopen ($hostname, $port = 80, & $errno, & $errstr, $timeout = 15) {

$fp =''

If (function_exists ('fsockopen')) {

$fp = @ fsockopen ($hostname, $port, $errno, $errstr, $timeout)

} elseif (function_exists ('pfsockopen')) {

$fp = @ pfsockopen ($hostname, $port, $errno, $errstr, $timeout)

} elseif (function_exists ('stream_socket_client')) {

$fp = @ stream_socket_client ($hostname.':'.$port, $errno, $errstr, $timeout)

}

Return $fp

}

Found that it is called fsockopen () function failed, search the Internet, found that most of the fsockopen () function does not support "http://"" such as the host prefix, to directly use the URL, such as www.163.com, or localhost, such as.

Solve

According to the online statement, I temporarily modified the code as follows:

If (! $fp = @ fsocketopen ('localhost', $port, $errno, $errstr, $timeout)) {

/ / if (! $fp = @ fsocketopen (($scheme = = 'https'? 'ssl': $scheme).': / /'. ($scheme = = 'https'? $host: ($ip? $ip: $host)), $port, $errno, $errstr, $timeout) {

$context = array (

'http' = > array (

'method' = > $post? 'POST': 'GET'

'header' = > $header

'content' = > $post

'timeout' = > $timeout

),

);

$context = stream_context_create ($context)

$fp = @ fopen ($scheme.'://'. ($scheme = = 'https'? $host: ($ip? $ip: $host)).':. $port.$path, 'baked, false, $context)

$fpflag = 1

}

Temporarily directly fix the first parameter to localhost, refresh the page, and finally communicate successfully:

Knowing the real reason, it is easy to modify the above temporary code in the right way, and there is no waste of ink here.

The above is how to solve the problem of UCenter communication failure under Nginx. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report