guzzle: Debug request option causes fatal error.

When I do this.

$client = new GuzzleHttp\Client(['base_uri' => 'http://httpbin.org']);
$client->request('GET', '/get', ['debug' => true]);

I get

Warning: curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE* in C:\xampp\htdocs\xxx\lib\guzzle\GuzzleHttp\Handler\CurlFactory.php on line 57

Warning: curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE* in C:\xampp\htdocs\xxx\lib\guzzle\GuzzleHttp\Handler\CurlFactory.php on line 57

Warning: curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE* in C:\xampp\htdocs\xxx\lib\guzzle\GuzzleHttp\Handler\CurlFactory.php on line 57

Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\xampp\htdocs\xxx\lib\guzzle\GuzzleHttp\Handler\CurlFactory.php:187 Stack trace: #0 C:\xampp\htdocs\xxx\lib\guzzle\GuzzleHttp\Handler\CurlFactory.php(485): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp\htdocs\xxx\lib\guzzle\GuzzleHttp\Handler\CurlFactory.php(147): GuzzleHttp\Handler\CurlFactory::retryFailedRewind(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Array) #2 C:\xampp\htdocs\xxx\lib\guzzle\GuzzleHttp\Handler\CurlFactor in C:\xampp\htdocs\xxx\lib\guzzle\GuzzleHttp\Handler\CurlFactory.php on line 187

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 5
  • Comments: 23 (4 by maintainers)

Commits related to this issue

Most upvoted comments

So in my case I just set debug to false…

When running on the PHP devserver, php 7.2.6 and windows 10, i was able to get it to work with

'debug' => fopen('php://stderr', 'w'),

When running on the PHP devserver, php 7.2.6 and windows 10, i was able to get it to work with

'debug' => fopen('php://stderr', 'w'),

This helped. I had the same issue on Windows 10, XAMPP with PHP 7.

This issue was automatically classified as stale because it lacks information or cannot be reproduced.

If you think the issue is still valid and/or misclassified, please comment on the issue thread and provide additional information (if possible).

Also, since the time maintainers can spend on the project is limited, please provide a possible solution if possible, especially if it involves a platform that we cannot test ourselves (Windows, very old/specific PHP versions, etc).

Issues marked as stale with no further activity will be marked as rotten at some point and will automatically be closed within 14 days.

We do this so that we can focus on high priority issues. Thank you for your understanding.

My hunch was right, it seems. Guzzle won’t work at all if the same instance of PHP is used to send the Request from Guzzle, and to respond that request. Basically, one instance of PHP on the same server is a no go.

How to (temporally) fix this? I just elevated a second PHP-CGI listening in port :667, and in NGINX I used the fastcgi_pass 127.0.0.1:667; for the http://game.dev/test. Guzzle worked successfully with results.

In other words, a PHP Instance for Guzzle and another PHP Instance to receive must be done.

May be from Guzzle this can be “fixed”, but I doubt it.

Just a heads up for those who are running the same PHP instance for Request and Responses.

When running on the PHP devserver, php 7.2.6 and windows 10, i was able to get it to work with

'debug' => fopen('php://stderr', 'w'),

Thanks this fix works for me

For anyone working with multiple Laravel sites locally, run php artisan config:cache on both sites might help Src: https://github.com/laravel/framework/issues/21533#issuecomment-334352170