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

Unable to send events after update libcurl to v8.1.0 #1537

Closed
rodolfoBee opened this issue May 22, 2023 · 7 comments
Closed

Unable to send events after update libcurl to v8.1.0 #1537

rodolfoBee opened this issue May 22, 2023 · 7 comments
Assignees

Comments

@rodolfoBee
Copy link
Member

After updating libcurl to 8.1.0 the Laravel SDK is not able to send events to Sentry, it fails with the following error:

[sentry-laravel] error: Failed to send the event to Sentry. Reason: "HTTP/2 stream 1 was reset for "https://o388665.ingest.sentry.io/api/5461612/envelope/".". | {"exception":{},"event":{}}

The PHP SDK also fails to send events, but silently.

https://github.com/curl/curl/releases/tag/curl-8_1_0
https://github.com/curl/curl/releases/tag/curl-8_0_1

Current workaround: downgrade to v8.0.1.

@krowinski
Copy link

krowinski commented May 23, 2023

The problem is in \Http\Client\Common\Plugin\DecoderPlugin::handleRequest as is adding header 'TE'
$request = $request->withHeader('TE', $encodings);

with values
"TE" => array:3 [ 0 => "gzip" 1 => "deflate" 2 => "chunked" ]

And RFC for HTTP/2 specifies The only exception to this is the TE header field, which MAY be present in an HTTP/2 request; when it is, it MUST NOT contain any value other than "trailers"."

https://httpwg.org/specs/rfc9113.html#rfc.section.8.2.2

Its connected to curl lib as on 8.1.0 we got error

curl -X POST https://google.com  -d ''  -H "TE: gzip"
curl: (56) HTTP/2 stream 1 was reset

and before is was ok

curl -X POST https://google.com  -d ''  -H "TE: gzip"                                                                                                                                                                                                                                                                               
<!DOCTYPE html>

But still php http client should not add invalid headers as curl seems to be more strict(?)

@mariandomanik
Copy link

Can confirm - either remove TE headers, or switch protocol to 1.1 in

vendor/symfony/http-client/CurlHttpClient.php
public function request

@cleptric
Copy link
Member

I opened an issue over at https://github.com/php-http/client-common/

@mariandomanik
Copy link

When code reaches DecoderPlugin, the protocol is set to 1.1, it is only switched to HTTP2 at CurlHttpClient, after the TE headers are already set

} elseif (\defined('CURL_VERSION_HTTP2') && (\CURL_VERSION_HTTP2 & CurlClientState::$curlVersion['features']) && ('https:' === $scheme || 2.0 === (float) $options['http_version'])) { $curlopts[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_2_0; }

In my opinion, the CurlHttpClient should verify it can switch to HTTP2 with the headers, or manage them accordingly after switching to HTTP2, but it is up to debate.

@cleptric
Copy link
Member

Appreciate the feedback, but let’s move this over to the repository in question.

@cleptric
Copy link
Member

We released v3.19.1 that enforces HTTP/1.1 if compression is enabled.

@pawelbaranski
Copy link

pawelbaranski commented Jun 15, 2023

if someones stumbles on the issue and upgrade to v3.19.1 is not helping then try to update symfony/http-client to v 5.4.16 at minimum.

HttplugClient in earlier version forced using http_version with null value, which results in setting \CURL_HTTP_VERSION_2_0 as default.

problem
https://github.com/symfony/http-client/blob/v5.4.15/HttplugClient.php#L262
fix
https://github.com/symfony/http-client/blob/v5.4.16/HttplugClient.php#L266

it is done upon request so setting default options as getsentry/sentry-php does is not helping

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

No branches or pull requests

5 participants