Skip to content

[HttpClient] Curl client always uses HTTP 2.0 even when specifying otherwise #37402

@relm

Description

@relm

Symfony version(s) affected: 4.4.10

Description
I'm experiencing an issue with random TransportException errors (seems to be server side related) so I'm attempting to use HTTP 1.1 instead of 2.0. The problem is, HttpClient always seems to use 2.0 even when specifying otherwise.

I have the following in framework.yaml:

http_client:
    max_host_connections: 1
    default_options:
        http_version: '1.1'

I also tried passing http_version => '1.1' to the $options parameter of request, still uses 2.0. Is there something I'm missing?

If I disable http2 on the httpd side (nginx) then it uses 1.1 as you'd expect. I should still be able to use 1.1 if 2.0 is enabled server side though right?

Example output with $r->getInfo('debug') from my logs:

  "details" => """
    * Found bundle for host api.test.net: 0x55d1dc5cfc20 [can multiplex]\n
    * Re-using existing connection! (#0) with host api.test.net\n
    * Connected to api.test.net (127.0.0.1) port 443 (#0)\n
    * Using Stream ID: 13 (easy handle 0x55d1dc57cc60)\n
    > GET /public/status HTTP/2\r\n
    Host: api.test.net\r\n
    accept: */*\r\n
    user-agent: Symfony HttpClient/Curl\r\n
    accept-encoding: gzip\r\n
    \r\n
    < HTTP/2 200 \r\n
    < server: nginx/1.17.10 (Ubuntu)\r\n
    < content-type: application/json\r\n
    < cache-control: no-cache, private\r\n
    < date: Tue, 23 Jun 2020 22:53:59 GMT\r\n
    < x-debug-token: cb2ac3\r\n
    < x-debug-token-link: https://api.test.net/_profiler/cb2ac3\r\n
    < x-robots-tag: noindex\r\n
    < x-content-type-options: nosniff\r\n
    < strict-transport-security: max-age=15768000\r\n
    < \r\n
    * Connection #0 to host api.test.net left intact\n
    """,
  "options" => [
    "http_version" => "1.1"
  ],
  "response" => "{"success":true,"status":"E1"}"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions