I want use GuzzleHttp
with Socks5 proxy
.
It's not working on Linux.
It's successfully workin on Windows.
(Same progam to Linux)
$ php index.php
PHP Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: Connection refused for URI https://api.ipify.org in /root/test/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php:311
Stack trace:
#0 /root/test/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(230): GuzzleHttp\Handler\StreamHandler->GuzzleHttp\Handler\{closure}()
#1 /root/test/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(322): GuzzleHttp\Handler\StreamHandler->createResource(Object(Closure))
#2 /root/test/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(58): GuzzleHttp\Handler\StreamHandler->createStream(Object(GuzzleHttp\Psr7\Request), Array)
#3 /root/test/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(35): GuzzleHttp\Handler\StreamHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#4 /root/test/vendor/guzzlehttp/guzzle/src/Middleware.php(31): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#5 /root/test/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(71): GuzzleHttp\Middleware::Gu in /root/test/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 72
composer require guzzlehttp/guzzle
composer.json
{
"require": {
"guzzlehttp/guzzle": "^7.2"
}
}
index.php
<?php
require('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$url = 'https://api.ipify.org';
$response = $client->get($url, [
'proxy' => "socks5://10.0.0.2:8080",
'timeout' => 60, // 60 second
'verify' => false
]);
var_dump($response->getBody()->getContents());
'proxy' => "socks5h://10.0.0.2:8080"
No effect to result.
Ref: https://github.com/guzzle/guzzle/issues/1484#issuecomment-306724234
'proxy' => "tcp://10.0.0.2:8080"
No effect to result.
Ref: https://github.com/guzzle/guzzle/issues/1484#issue-157978804
https://pypi.org/project/pproxy/
$ pproxy -l socks5://0.0.0.0:8080
Ubuntu 20.04.1 LTS
+ php 7.3.24-3
Not workingUbuntu 20.04.1 LTS(WSL)
+ php 7.4.3
Not woringWindows 10 1903 64bit
+ php 7.2.12
Successfully workingJust install php-curl
apt install php7.3-curl
$ php -i | grep cURL
(No output)
$ php -i | grep cURL
cURL support => enabled
cURL Information => 7.68.0
Successfully working
$ php index.php
string(15) "xxx.xxx.xxx.x"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With