-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
retry on 400 RequestTimeout #411
Conversation
I sometimes get "Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed." Seems like these errors should be automatically retried.
@andrewgaul this may solve your problem |
I am unsure why I get this error to begin with. Here's some log for this error:
This is run within ec2 to s3 bucket in the same region. Noticed how it took 48 seconds to get this error uploading a 5MB part. |
Hi @kahing thanks for creating the PR. In the error log you provided were you using the
Would you be able to include the error code and message that you received as a response for the UploadPart APi call? |
Ah yes, the log is with this PR included. It wasn't retrying before. The original error looks something like:
I am still very baffled why this error happens at all. |
From what i can find this error occurs when the service does not read the full Sometimes this could occur the SDK retrying a request which failed, but for some reason did not rewind the request body, or a data corruption occurred. Are you able to reproduce this bug consistently? I don't see any reason not to take in this change, but i want to make sure there is not another issue going on in the SDK that will be hidden with the retries. Related to: |
I see this very often. Initially I omitted the Content-Length and just relied on the sdk to figure it out (the Body is a bytes.NewReader([]byte)), but that and manually setting ContentLength to len(buf) had the same results. If I provide my own reader and log from WriteTo(), I can see that net/http/Client reads from my buffer 4KB at a time, and at some point would stop, and then usually after another 43 seconds or so I will get the error. |
I should add that my buffers are always 5MB and usually this stops after a few hundred KB. |
So it sounds like in your case the full 5mb is not being uploaded. Is this correct? Something happens causing only part of the bites to be sent. Are you connecting through a proxy? Also is your app running on a server like EC2 instance or locally on a dev box? |
This is running on ec2 c4.xlarge in us-west-2a connecting to a bucket in us-west-2 |
Thanks for the info! Pulling in the PR. I would not of expected that delay in an EC2 instance. Out of curiosity is your data coming from an |
I do not expect the delay either and the buffer is a regular []byte. It seems to happen more on https and less (or not at all) on http. Just got a tcpdump and will look into it soon. |
Merged in this PR, ae0b628 |
I sometimes get "Your socket connection to the server was not read
from or written to within the timeout period. Idle connections
will be closed."
Seems like these errors should be automatically retried.