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

Post es http err:http2: Transport: cannot retry err [http2: Transport received Server's graceful shutdown GOAWAY] after Request.Body was written; define Request.GetBody to avoid this error #1443

Open
franklwel1990 opened this issue Dec 4, 2020 · 21 comments
Labels
Milestone

Comments

@franklwel1990
Copy link

Please use the following questions as a guideline to help me answer
your issue/question without further inquiry. Thank you.

Which version of Elastic are you using?

github.com/olivere/elastic/v7 v7.0.22

Please describe the expected behavior

Post "https://aaaes.amazonaws.com/statistics_%2A/_search": http2: Transport: cannot retry err [http2: Transport received Server's graceful shutdown GOAWAY] after Request.Body was written; define Request.GetBody to avoid this error
server/ChessCronApi/es.(*FundData).FundMoneySearch

Please describe the actual behavior

Online requests for es addresses often report errors on stage

Any steps to reproduce the behavior?

no

@olivere
Copy link
Owner

olivere commented Dec 4, 2020

I need to further investigate. There's an ancient issue at golang/go#25009 which describes this bug but is closed at least after Go 1.12. I've never seen this message after years of running in production.

@olivere olivere added the bug label Dec 4, 2020
@GrahamWalters
Copy link

I'm also seeing this error, but we're using a GET request

Get "https://xyz.us-east-1.es.amazonaws.com/xyz/_doc/1157": http2: Transport: cannot retry err [http2: Transport received Server's graceful shutdown GOAWAY] after Request.Body was written; define Request.GetBody to avoid this error

github.com/olivere/elastic/v6 v6.2.16
go version go1.15 linux/amd64

@fengyuxx
Copy link

Same error in bulk write request. It looks like we are all using aws?

Post https://xxxxxxxxx.us-west-2.es.amazonaws.com/_bulk: http2: Transport: cannot retry err [http2: Transport received Server's graceful shutdown GOAWAY] after Request.Body was written; define Request.GetBody to avoid this error.

@rbUUbr
Copy link

rbUUbr commented Dec 17, 2020

@olivere seems like usage of go 1.15 version should help to avoid this problem according to this thread: golang/go#32441

@Atply234
Copy link

Atply234 commented May 6, 2021

Any updates on this ? Im facing the similar issue and also upgrade of go to 1.15 did not help.

@juhovuori
Copy link

I'm also seeing this regularly on go 1.16.

@kahluw2
Copy link

kahluw2 commented Aug 11, 2021

I am seeing this in go 1.14 and 1.15 both. Any updates on this?

@olivere
Copy link
Owner

olivere commented Aug 12, 2021

It looks like this is the source of the error. I'm looking into this in the next release.

It should be a simple fix.

P.S.: Go 1.14 is no longer supported, and 1.15 is on the edge (once 1.17 comes out in August 2021). I think it's a good idea to update anyway—even if it doesn't fix your issue.

@olivere olivere added this to the 7.0.28 milestone Aug 12, 2021
@Hhhha
Copy link

Hhhha commented Aug 13, 2021

Maybe it's http2. You can set http.Transport.ForceAttemptHTTP2 to false.

@olivere olivere modified the milestones: 7.0.28, 7.0.29 Aug 30, 2021
@olivere
Copy link
Owner

olivere commented Sep 16, 2021

Anybody can confirm this still happens in the supported Go versions, i.e. Go 1.16 and Go 1.17 (at the time I'm writing this)?

@olivere olivere modified the milestones: 7.0.29, 7.0.30 Sep 16, 2021
@vladiacob
Copy link

@olivere It's still happening pretty often. We didn't have that issue until we migrated from elasticsearch to AWS OpenSearch.

@olivere
Copy link
Owner

olivere commented Sep 19, 2021

@olivere It's still happening pretty often. We didn't have that issue until we migrated from elasticsearch to AWS OpenSearch.

@vladiacob May I ask which Go version you're using?

@vladiacob
Copy link

@olivere 1.17.1 is the version

@vladiacob
Copy link

Do you have any idea how we can solve the issue? Is happening really often.

@jaakkotuosa
Copy link

Happening multiple times a day for me on go 1.17.1 + AWS OpenSearch (Elasticsearch 7.9, connections from ECS, through VPN)

@hexa00
Copy link

hexa00 commented Nov 17, 2021

We experienced this issue on go 1.16 also and worked-around it by building with:
go build -tags nethttpomithttp2

@ceverus
Copy link

ceverus commented Nov 29, 2021

I am seeing this in go 1.14.

@pgvishnuram
Copy link

Yes its observed in aws opensearch and aws elasticsearch.

@pgvishnuram
Copy link

Issue can be reproduced when you try to write huge data or simultaneous data writes to elastic search

@nblizard
Copy link

nblizard commented Dec 9, 2021

We were not running into this issue when using only http, but once we started using https, this issue cropped up for us. This appeared to occur very intermittently, but it was reproducible and occurred when using basic auth or AWS IAM Auth4.

@hexa00 's solution above did indeed work for us, but due to our codebase, we were hesitant to to use a compiler directive to affect all httpClients.

After some research, I believe I have a solution. I believe the piece of info we are looking for is outlined here: https://pkg.go.dev/net/http#pkg-overview. "Programs that must disable HTTP/2 can do so by setting Transport.TLSNextProto (for clients) or Server.TLSNextProto (for servers) to a non-nil, empty map. Alternatively, the following GODEBUG environment variables are currently supported."

Our full solution below appears (thus far) to work for us:

httpClient := &http.Client{
	Transport: &http.Transport{
		TLSNextProto: map[string]func(string, *tls.Conn) http.RoundTripper{},
	},
}

signingClient := elasticaws.NewV4SigningClientWithHTTPClient(credentials.NewStaticCredentials(env.ESKeyID, env.ESSecretKey, ""), env.AWSRegion, httpClient)
options := []elastic.ClientOptionFunc{elastic.SetURL(env.ESURL), elastic.SetHttpClient(signingClient), elastic.SetHealthcheck(false), elastic.SetSniff(false)}

client := elastic.NewClient(options...)

@olivere olivere modified the milestones: 7.0.30, 7.0.31 Dec 17, 2021
@olivere olivere removed this from the 7.0.31 milestone Jan 7, 2022
@olivere olivere added this to the 7.0.32 milestone Jan 7, 2022
@olivere olivere modified the milestones: 7.0.32, 7.0.33 Mar 19, 2022
@JoydS
Copy link

JoydS commented Mar 27, 2023

Hello guys,
So basically we need to disable http2 to fix this problem ?
On my side, it's not on a post request but a get request.
Would be great to have a fix on this, thanks guys

RouxAntoine added a commit to RouxAntoine/reproxied that referenced this issue Apr 10, 2023
Get http2: Transport: cannot retry err [http2: Transport received Server's graceful shutdown GOAWAY] after Request.Body was written; define Request.GetBody to avoid this error
olivere/elastic#1443 (comment)
RouxAntoine added a commit to RouxAntoine/reproxied that referenced this issue Apr 10, 2023
Get http2: Transport: cannot retry err [http2: Transport received Server's graceful shutdown GOAWAY] after Request.Body was written; define Request.GetBody to avoid this error
olivere/elastic#1443 (comment)
RouxAntoine added a commit to RouxAntoine/reproxied that referenced this issue May 1, 2023
Get http2: Transport: cannot retry err [http2: Transport received Server's graceful shutdown GOAWAY] after Request.Body was written; define Request.GetBody to avoid this error
olivere/elastic#1443 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests