【问题标题】:Connection timeout error while updating composer on Digital Ocean在 Digital Ocean 上更新作曲家时出现连接超时错误
【发布时间】:2019-10-28 17:57:08
【问题描述】:

我可以通过 ssh 进入我的 droplet。我还能够进行 apt update 和 apt upgrade。

当我尝试运行 sudo composer self-update 或 composer update 时,出现连接超时错误。

The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Connection timed out  

ufw status的输出

To      Action    From
22      ALLOW     Anywhere
80      ALLOW     Anywhere
443     ALLOW     Anywhere
25      ALLOW     Anywhere
10000   ALLOW     Anywhere     

composer diagnose的输出

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "http://packagist.org/packages.json" file    could not be downloaded: failed to open stream: Connection timed out
Checking https connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file    could not be downloaded: failed to open stream: Connection timed out
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: 

[Composer\Downloader\TransportException]                                     
The "https://getcomposer.org/version" file could not be downloaded: failed   
to open stream: Connection timed out

composer --version的输出

Composer version 1.0-dev (9e9c1917e1ed9f3f78b195a785aee3c6dc3cb883) 2015-11-23 10:31:23  

curl IL http://packagist.org/packages.json的输出

HTTP/1.1 200 OK
Server: nginx
Date: Sun, 10 Dec 2017 08:40:20 GMT
Content-Type: application/json
Content-Length: 1302
Last-Modified: Sun, 10 Dec 2017 08:38:28 GMT
Connection: keep-alive
ETag: "5a2cf284-516"
Cache-Control: private, max-age=0, no-cache
Accept-Ranges: bytes  

我尝试手动获取最新作曲家的副本,但它也不起作用

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"的输出

PHP Warning:  copy(https://getcomposer.org/installer): failed to open stream: Connection timed out in Command line code on line 1  

可能是什么原因?我一直工作到大约一周前。我能够访问(浏览)托管在我的 droplett 上的网页。我还能够进行 apt update 和 apt upgrade。

【问题讨论】:

  • 看看getcomposer.org/doc/articles/… - 这看起来像你的问题
  • @NicoHaase 这似乎有效 - 至少让 sudo composer self-update 有效。然而,项目目录中的 composer update 非常慢 - 似乎需要很长时间才能更新依赖项。我想我将不得不进一步谷歌以了解为什么作曲家更新如此缓慢。再次感谢这个问题似乎与液滴上不正确的 ipv6 配置有关。如果您将其作为答案发布,我很乐意将其标记为正确答案。

标签: composer-php ubuntu-16.04 digital-ocean


【解决方案1】:

您可以以 root 身份运行此命令以使 IPV4 比 IPV6 更优先:

sudo sh -c "echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf"

【讨论】:

  • 谢谢,整个上午都在寻找这个。这是我的网络«我猜»的某种问题,所以我无法访问 throw ipv6,但它适用于 ipv4。谢谢兄弟。
【解决方案2】:

https://getcomposer.org/doc/articles/troubleshooting.md#operation-timed-out-ipv6-issues- 可以解决您的问题。如果之后composer update 变慢,请尝试使用更新的 PHP 版本运行它。使用 PHP 7 而不是 PHP 5 运行它会大大加快速度

【讨论】:

    【解决方案3】:

    我在上次执行 composer 命令时还发现了一个关于此超时的错误。运行“compose diag”然后重新启动命令解决问题,如果它与ipv6无关

    【讨论】:

    • 您能进一步解释一下吗? composer diag如何解决问题?
    • 我不知道到底发生了什么,但有时它可以解决问题。看起来composer diag 不只是诊断,而是试图解决一些问题或改变一些东西
    【解决方案4】:

    我的问题是 PHP 7.2 引起的,切换回 PHP 7.1 'sphp 7.1' 后,再次运行命令 'composer update' 就可以了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-27
      • 1970-01-01
      • 2016-05-14
      • 2021-08-07
      • 2013-05-30
      • 2015-09-13
      • 1970-01-01
      • 2016-02-02
      相关资源
      最近更新 更多