References:
http://docs.guzzlephp.org/en/stable/request-options.html#proxy
Env :
GuzzleHttp/6.2.1
curl/7.47.0
PHP/7.1.3-3+deb.sury.org~xenial+1
I am trying to use proxy server with async Guzzle calls.
I have discovered that when I set proxy when creating a client, it works.
e.g.
new Client(['proxy' => 'tcp://64.140.159.209:80'])
However when create a client with no options .. and then set proxy on Request, proxy is not used at all, and guzzle makes a direct connection from client machine to server machine. That is confirmed by hitting http://httpbin.org/ip and inspecting the Origin returned by httpbin.
I need the ability to set proxy on each request.
Here is relevant code:
$client = new Client();
$request = new Request(
'GET',
'http://httpbin.org/ip',
['proxy' => 'tcp://64.140.159.209:80']
);
$client->sendAsync($request)
->then(
...closure here
// process here
);