1

我的网络服务器(使用 nginx 托管 facebook 应用程序)开始收到错误消息

*907768 FastCGI sent in stderr: "Invalid IPv6 configuration on server, Please disable or get native IPv6 on your server" while reading response header from upstream, client:...

此错误的原因可能是什么?我并不总是明白这一点。

4

1 回答 1

2

该错误来自 php 代码,更具体地说 - facebook sdk。当 facebook 代码尝试连接到 ipv6 地址并且无法连接到网络时会抛出它,这很可能是由于系统中启用了 ipv6 但没有 ipv6 连接(来自base_facebook.php的引用):

// With dual stacked DNS responses, it's possible for a server to
// have IPv6 enabled but not have IPv6 connectivity.  If this is
// the case, curl will try IPv4 first and if that fails, then it will
// fall back to IPv6 and the error EHOSTUNREACH is returned by the
// operating system.
if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) {
    $matches = array();
    $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
    if (preg_match($regex, curl_error($ch), $matches)) {
      if (strlen(@inet_pton($matches[1])) === 16) {
        self::errorLog('Invalid IPv6 configuration on server, '.
                       'Please disable or get native IPv6 on your server.');
        self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
        curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
        $result = curl_exec($ch);
      }
    }
}

处理此问题的正确方法是在系统中禁用 ipv6 或获取一些 ipv6 连接。或者,应该可以通过在您的代码中要求 facebook 代码始终使用 ipv4 来抑制错误:

Facebook::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
于 2012-09-18T23:15:16.823 回答