composer / composer

Dependency Manager for PHP
https://getcomposer.org/
MIT License
28.58k stars 4.54k forks source link

file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy #2169

Closed stefanmerk closed 11 years ago

stefanmerk commented 11 years ago

Hey there,

I am trying to run composer on a company server which is behind a firewall. I already set HTTP_PROXY and HTTPS_PROXY (+ both in lowercase), it doesn't seem to help. Also the REQUESTFULLURI flags are set to false! (both HTTP and HTTPS) (I can however connect to HTTPS and HTTP with CURL)

I already googled everything that could help me, unfortunately with no success for my particular problem.

Also the Server runs OpenSSL with v1.0.0 from March 2012

I also ran composer diag:

Checking platform settings: FAIL

Your PHP (5.3.3) is quite old, upgrading to PHP 5.3.4 or higher is recommended.
Composer works with 5.3.2+ for most people, but there might be edge case issues.
Checking http connectivity: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy
Checking HTTP proxy: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy
Checking HTTP proxy support for request_fulluri: FAIL
Unable to assert the situation, maybe packagist.org is down (The "http://packagist.org/packages.json" file could not be downloaded (HTTP/1.0 400 Bad Request))
Checking HTTPS proxy support for request_fulluri: FAIL
Unable to assert the situation, maybe github is down (The "https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0" file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy)
Checking composer.json: 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: Cannot connect to HTTPS server through proxy

diagnose
Seldaek commented 11 years ago

Any chance you can check with a more recent php version from within the same network conditions?

stefanmerk commented 11 years ago

Actually, it is a more recent PHP Version (only the number is the old one – don't ask me why)

But I was able to run composer on my local machine (behind the same proxy), but with Windows on it and I was executing the following command: SET HTTP_PROXY=http://username:pass@companyproxy:8080 && SET HTTPS_PROXY=http://username:pass@companyproxy:8080 && SET HTTP_PROXY_REQUEST_FULLURI=1 && SET HTTPS_PROXY_REQUEST_FULLURI=0 && php composer.phar update friendsofsymfony/user-bundle

Anything more what I can do, or what I can check for – maybe I am missing something?

Note: I do not have admin rights! I am just a normal user. (If this has anything to do with it.)

Seldaek commented 11 years ago

Admin access should not be necessary. If you have a hacked-together PHP with an incorrect version though maybe you have other issues and https doesn't work properly? Can you do a normal file_get_contents of https content? Like: php -r 'var_dump(file_get_contents("https://packagist.org/packages.json"));' or maybe try php -r 'var_dump(file_get_contents("https://google.com"));' too. Both output a string for me..

gaving commented 11 years ago

Having the same misery here behind my corporate firewall. Things used to be fine, so not sure what's changed.

Diagnostics:-

ubuntu:~/test% echo $http_proxy
http://user:pass@wwwproxy:8080/
ubuntu:~/test% echo $https_proxy
http://user:pass@wwwproxy:8080/
ubuntu:~/test% php --version && php -i | grep -C 5 ssl
PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch (cli) (built: Jun 13 2012 17:20:55)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Thread Safety => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls
Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

This server is protected with the Suhosin Patch 0.9.10
Copyright (c) 2006-2007 Hardened-PHP Project
--
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off

openssl

OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.0.1 14 Mar 2012
OpenSSL Header Version => OpenSSL 1.0.1 14 Mar 2012
ubuntu:~/test% php ../composer.phar diag                                                                                                                                              Checking platform settings: OK                                                                                                                                                        Checking http connectivity: FAIL                                                                                                                                                      [Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy  Checking HTTP proxy: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy
Checking HTTP proxy support for request_fulluri: OK
Checking HTTPS proxy support for request_fulluri: FAIL
Unable to assert the situation, maybe github is down (The "https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0" file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy)
Checking composer.json: FAIL
name : is missing and it is required
description : is missing and it is required
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
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: Cannot connect to HTTPS server through proxy

diagnose

Install:-

ubuntu:~/test% php ../composer.phar -v install
Loading composer repositories with package information

  [Composer\Downloader\TransportException]
  The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy

Exception trace:
() at phar:///home/gavin/composer.phar/src/Composer/Util/RemoteFilesystem.php:205
Composer\Util\RemoteFilesystem->get() at phar:///home/gavin/composer.phar/src/Composer/Util/RemoteFilesystem.php:76
Composer\Util\RemoteFilesystem->getContents() at phar:///home/gavin/composer.phar/src/Composer/Repository/ComposerRepository.php:541
Composer\Repository\ComposerRepository->fetchFile() at phar:///home/gavin/composer.phar/src/Composer/Repository/ComposerRepository.php:397
Composer\Repository\ComposerRepository->loadRootServerFile() at phar:///home/gavin/composer.phar/src/Composer/Repository/ComposerRepository.php:224
Composer\Repository\ComposerRepository->hasProviders() at phar:///home/gavin/composer.phar/src/Composer/DependencyResolver/Pool.php:84
Composer\DependencyResolver\Pool->addRepository() at phar:///home/gavin/composer.phar/src/Composer/Installer.php:336
Composer\Installer->doInstall() at phar:///home/gavin/composer.phar/src/Composer/Installer.php:210
Composer\Installer->run() at phar:///home/gavin/composer.phar/src/Composer/Command/InstallCommand.php:97
Composer\Command\InstallCommand->execute() at phar:///home/gavin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
Symfony\Component\Console\Command\Command->run() at phar:///home/gavin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:897
Symfony\Component\Console\Application->doRunCommand() at phar:///home/gavin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:191
Symfony\Component\Console\Application->doRun() at phar:///home/gavin/composer.phar/src/Composer/Console/Application.php:117
Composer\Console\Application->doRun() at phar:///home/gavin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:121
Symfony\Component\Console\Application->run() at phar:///home/gavin/composer.phar/src/Composer/Console/Application.php:83
Composer\Console\Application->run() at phar:///home/gavin/composer.phar/bin/composer:43
require() at /home/gavin/composer.phar:15

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]

Curling manually works ok (if ignoring certificates):-

ubuntu:~/test% curl -k https://packagist.org/packages.json
{"packages":[],"notify":"\/downloads\/%package%","notify-batch":"\/downloads\/","providers-url":"\/p\/%package%$%hash%.json","search":"\/search.json?q=%query%","provider-includes":{"p\/provider-active$%hash%.json":{"sha256":"b10aeb4465ef0133f641c191753d785003922258ee927f330118039d7e216eb8"},"p\/provider-archived$%hash%.json":{"sha256":"e57ba51556f01f4074be158f622edd0312672809e8485b686d96185b2152c281"},"p\/provider-latest$%hash%.json":{"sha256":"057c371f4efbc2fb1bc7de5663661563f6be89474cb6d2a2fcc85c56b4383599"},"p\/provider-stale$%hash%.json":{"sha256":"1f154578284376e0512266a0ea6d892ab2076fd2d6c929c90cb95d64799b0bdc"}}}%

Issues with these though:-

ubuntu:~/test% php -r 'var_dump(file_get_contents("https://packagist.org/packages.json"));'
PHP Warning:  file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in Command line code on line 1
PHP Warning:  file_get_contents(https://packagist.org/packages.json): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in Command line code on line 1
bool(false)

ubuntu:~/test% php -r 'var_dump(file_get_contents("https://google.com"));'
PHP Warning:  file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in Command line code on line 1
PHP Warning:  file_get_contents(https://google.com): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in Command line code on line 1
bool(false)
tprabhaker commented 11 years ago

Hi, Even i am on the same loop, can anyone please help me, i did set HTTP_PROXY and HTTPS_PROXY , is this something the firewall issue?

Package "friendsofsymfony/user-bundle" listed for update is not installed. Ignor ing. Loading composer repositories with package information The "https://packagist.org/packages.json" file could not be downloaded: php_netw ork_getaddresses: getaddrinfo failed: No such host is known. failed to open stream: php_network_getaddresses: getaddrinfo failed: No such hos t is known. https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date Updating dependencies (including require-dev)

[Composer\Downloader\TransportException] The "http://packagist.org/p/xxxxx/xxxxxxxx$4a4b53b97ad3ec08e4f2d00a2f6 f639e653dbba4eacba25782f346c7af3f1c67.json" file could not be downloaded: p hp_network_getaddresses: getaddrinfo failed: No such host is known. failed to open stream: php_network_getaddresses: getaddrinfo failed: No suc h host is known.

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [ -o|--optimize-autoloader] [packages1] ... [packagesN]

But, i can able to access the json file from browser...

purwandi commented 11 years ago

Same here ... any suggestion ?

stefanmerk commented 11 years ago

I don't really know why or how. But I was able to set all the vars correctly and running composer diag so, it was running through correctly. Try setting all the things and running composer diag until all settings are set correctly.

Relequestual commented 9 years ago

@stefanmerk Can you remember what specific things you set? I am coming up against the same problem and the sysadmins have just called "time of death" on my ticket for this =[

thusithasumanadasa commented 9 years ago

I think its a DNS problem

laddhoffman commented 8 years ago

On my system it looks like it's trying to use IPv6 and my firewall was blocking that.

spotatoes commented 7 years ago

I know this issue is closed, but there are no definitive recommendations and I am also having this issue when trying to install. I am 99% sure it's not a DNS or firewall issue as I've made no significant changes to either from a clean install of Ubuntu 16.04.

All settings correct for using Composer
Downloading...
The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Connection timed out
Retrying...
The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Connection timed out
Retrying...
The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Connection timed out
The download failed repeatedly, aborting.

Although All settings correct for using Composer, when I run composer diag I get the following error before the same /versions URL issue as above:

Checking http connectivity to packagist: WARNING
[Composer\Downloader\TransportException] The "http://packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection timed out

Is there anything I can look into?

asanoturna commented 7 years ago

i have same problem that @spotatoes

vedro-compota commented 7 years ago

similar problem on ubuntu 16.04 -- suddenly after nornal working (may be github block downloading)?

Loading composer repositories with package information

  [Composer\Downloader\TransportException]                                     
  The "https://api.github.com/repos/it-for-free/FileUploader" file could not   
  be downloaded: failed to open stream: Connection timed out                   

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
gbryant200 commented 6 years ago

I'm having this same issue - has anyone found a fix? I'm leaning toward an openSSL issue with PHP but don't know how to fix it. I can file_get_contents and curl successfully on my local network. I have my HTTP and HTTPS proxies set.

from the command line to test: curl https://packagist.org/packages.json ----> works php -r "echo file_get_contents('https://packagist.org/packages.json');" ----------> fails to open stream php -r "echo curl_exec(curl_init('https://packagist.org/packages.json'));" ---------> works

OpenSSL 1.0.2g 1 Mar 2016 PHP 7.0.22-0ubuntu0.16.04.1 (cli)

HELP! & THANKS!

vedro-compota commented 6 years ago

@gbryant200 in my case all started work after some time by itself. So the reason is "mysterious" for me)

Your examples works for me too, e.g.:

php -r "echo file_get_contents('https://packagist.org/packages.json');"

give:

{"packages":[],"notify":"\/downloads\/%package%","notify-batch":"\/downloads\/","providers-url":"\/p\/%package%$%hash%.json","search":"\/search.json?q=%query%&type=%type%","provider-includes":{"p\/provider-2013$%hash%.json":{"sha256":"056ceb64027ee92bd10ba9c39d9cf34377c693047708dc6dad6f5c20f1efd63d"},"p\/provider-2014$%hash%.json":{"sha256":"b7c785fb309ae1a62fe2a4683b0567608b658978ef1423d70b70169ab00e4217"},"p\/provider-2015$%hash%.json":{"sha256":"265500a9d9b53aa41bbc2fa8a96d0bf9363b65421c7841514e8567577438bbc8"},"p\/provider-2016$%hash%.json":{"sha256":"ed9dcc23638cd306b496c12637d1498ff71d5c05def146048c57b3b376f97749"},"p\/provider-2017$%hash%.json":{"sha256":"8a86eaff6c826b8229d20d607d548781879e988a80a656b8c643cc721ba1ec56"},"p\/provider-2017-04$%hash%.json":{"sha256":"c86648e90aa74c610ec54b5ea294565afba1966dd7baebae3f438dcf17d3a719"},"p\/provider-2017-07$%hash%.json":{"sha256":"03550112a6a614bc28fe977a7ec947138d42246e0d1c9f8b316a01e67e536d76"},"p\/provider-2017-10$%hash%.json":{"sha256":"b33ccb6ea356a746c217f60371a330e2794c5b73b8145b415210c5e518109370"},"p\/provider-archived$%hash%.json":{"sha256":"8b133134b93da87586d9fb3504cf769ed67211cead8fe9cf451545f3a75447b1"},"p\/provider-latest$%hash%.json":{"sha256":"85ecf6b30739e2628f7e18899298eb1fd03973df1734299d603242c921b6dcf5"}}}
iuli-dercaci commented 6 years ago

OK, in my case there was a problem with IPv6, solved it by disabling it in /etc/sysctl.conf by adding in the bottom

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

and running sudo sysctl -p to reload config

source

eduan commented 5 years ago

@gbryant200 did you solve that? I'm facing the same issue.

gbryant200 commented 5 years ago

I had proxy authentication issues. Curl has its own proxy settings; Apt has its own proxy settings and they don't all parse the strings the same way - very frustrating.

export http_proxy=http://domain\\username:password@proxy.address:port" typically works. Look up proxy settings for curl; I can't recall but I think they were different.

same for https_proxy; however some require the \ to be escaped, some utilities didn't. I tried "" the string, etc. This was back on Ubuntu 16.04.

drug200221 commented 1 year ago

The problem appeared after replacing the switch (apparently some connection settings were lost) I tried to set it up but in the end connected from the modem and everything worked ... But another problem appeared - the docker loads packages for a long time at such a speed