symfony: [HttpClient] TransportException on multiple requests
Symfony version(s) affected: branch 4.4
Description
I know this is usually a server issue, But Im confident it isn’t. I make a request like:
$client = new CurlHttpClient();
$response = $client->request(
'GET',
'https://foo.eu.auth0.com/api/v2/users?search_engine=v3&q=email%3A%22tobias%2Bmanager%40happyr.com%22',
[
'headers'=> ['Authorization' => 'Bearer eyJ0eXAiOiJ...'],
]
);
$x = $response->getStatusCode();
//$this->assertSame(200, $x);
$response = $client->request(
'DELETE',
'https://foo.eu.auth0.com/api/v2/users/auth0%7C5d2f790e26a0cf1347f7a/roles',
[
'headers'=> ['content-type' => 'application/json', 'Authorization' => 'Bearer eyJ0eXAiOiJ...'],
'body' => '{"roles":["rol_ipXgFzjd2cH5"]}',
]
);
$y = $response->getStatusCode();
//$this->assertSame(204, $y);
Notes:
- A) I tried doing the exact same request in Buzz and it works perfectly…
- B) My Authorization header is 1034 characters long.
- C) If I remove the
content-typeheader from the second request then it works - D) If I only do the DELETE request, it also works.
The exception
Symfony\Component\HttpClient\Exception\TransportException: Failed sending data to the peer for "https://foo.eu.auth0.com/api/v2/users/auth0%7C5d2939f790e26a0cf1347f7a/roles".
src/Symfony/Component/HttpClient/Chunk/ErrorChunk.php:105
src/Symfony/Component/HttpClient/Response/CurlResponse.php:124
src/Symfony/Component/HttpClient/Response/ResponseTrait.php:67
src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php:95
Caused by
Symfony\Component\HttpClient\Exception\TransportException: Failed sending data to the peer for "https://foo.eu.auth0.com/api/v2/users/auth0%7C5d2939f790e26a0cf1347f7a/roles".
src/Symfony/Component/HttpClient/Response/CurlResponse.php:262
src/Symfony/Component/HttpClient/Response/ResponseTrait.php:289
src/Symfony/Component/HttpClient/Response/CurlResponse.php:124
src/Symfony/Component/HttpClient/Response/ResponseTrait.php:67
src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php:95
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (13 by maintainers)
Nicolas and I debugged this together: Running
php --ri curl | grep "cURL Information"will give you the version of curl you are using. This bug in not present in 7.58.0 but it is in 7.64.0. Ie, the higher version is broken.When using HTTP 1.1 instead of HTTP 2.0 it was working. That will lead us to believe that there is a bug in curl when using h2+reusing connections.
My workaround at the moment is to use HTTP 1.1.
or if one uses the component with the FrameworkBundle:
Should be fixed by https://github.com/symfony/symfony/pull/33444/files#r320345688
Thank you for your response.
Here is the debug info from both requests. I caught the exception from the second
$response->getStatusCode();and thenvar_dump($response->getInfo('debug'));: