Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect in curl_multi causes hang #211

Open
Daniel15 opened this issue Sep 9, 2017 · 5 comments
Open

Redirect in curl_multi causes hang #211

Daniel15 opened this issue Sep 9, 2017 · 5 comments

Comments

@Daniel15
Copy link

Daniel15 commented Sep 9, 2017

Repro:

\VCR\VCR::turnOn();
\VCR\VCR::configure()
  ->setCassettePath(__DIR__ . '/fixtures');
\VCR\VCR::insertCassette('hello-world');

$client = new \GuzzleHttp\Client();

$result = $client->get('https://httpbin.org/redirect/1');
echo "First request completed\n";

$results = \GuzzleHttp\Promise\unwrap([
  $client->getAsync('https://httpbin.org/redirect/1'),
  $client->getAsync('https://httpbin.org/redirect/1'),
]);
echo "Second request completed\n";

The first request completes (and correctly follows the redirect), but the second request hangs indefinitely. Guzzle itself handles this correctly, and it does not hang if VCR is disabled.

Daniel15 added a commit to Daniel15/BuildSize that referenced this issue Sep 10, 2017
Update CircleCI code to avoid redirect, in order to avoid php-vcr/php-vcr#211
@darxmac
Copy link

darxmac commented Jan 11, 2018

Any ideas on how to fix this ? I'm trying to use php-vcr to test against Azure-php. If something calls the azure api once, it works, but the second call makes the recording hang.

@killua99
Copy link

Did you find anything @darxmac I'm running with the same behaviour, the VCR hangs on any request POST via cURL. It has to be related to a lack of Content-Lenght in the response header. I can't yet confirm it 100% but many of google search point to that.

@darxmac
Copy link

darxmac commented Feb 20, 2018 via email

@moufmouf
Copy link
Contributor

Hey guys! If you are still facing this issue, it should be solved by #248.

renatomefi pushed a commit that referenced this issue May 30, 2018
### Context

When using PHP-VCR with Guzzle 6 with async requests, the first request is playing correctly but the next request is putting Guzzle in an infinite loop.

It took me a whole day but I traced back this problem to the way the "curl_reset" hook is written. It clears the request but not the response. Hence, when another request is performed (even on a different URL) the same response is sent. This weird behaviour is causing an infinite loop in Guzzle 6.

This problem is probably exactly the same as the issue #211. This PR should fix it.

### What has been done

The first commit of this PR contains only the failing test (to showcase the problem). You see that the test never completes (because of the infinite loop): https://travis-ci.org/php-vcr/php-vcr/jobs/366140696

The second commit is the fix. I simply added one line in the curl_reset hook to remove the response as well as the request.

Note: this PR is based on the branch from PR #246 since I need unit tests from Guzzle 6 that are not yet merged.
@renatomefi
Copy link
Member

Please try to use v1.4.4 to see if the problem is solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants