How can I troubleshoot the error "Your socket connection to the server was not read from or written to within the timeout period" from Amazon S3?
Last updated: 2019-12-20
I'm trying to upload files to Amazon Simple Storage Service (Amazon S3) using the AWS Command Line Interface (AWS CLI) or an AWS SDK. However, I'm getting the following error:
Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed. (Service: Amazon S3; Status Code: 400; Error Code: RequestTimeout)
How can I fix this?
When the connection between the client and the Amazon S3 server remains idle for 20 seconds or longer, Amazon S3 closes the connection. This results in the 400 RequestTimeout error. To troubleshoot this error, check the following:
The number of bytes set in the "Content-Length" header is more than the actual file size
When you send an HTTP request to Amazon S3, Amazon S3 expects to receive the amount of data specified in the Content-Length header. If the expected amount of data isn't received by Amazon S3, and the connection is idle for 20 seconds or longer, then the connection is closed. Be sure to verify that the actual file size that you're sending to Amazon S3 aligns with the file size that is specified in the Content-Length header.
Network issues like high latency, packet loss, and congestion
If a few packets or all packets are dropped because of a slow or poor network connection, then Amazon S3 waits for the expected number of bytes to be received. If the connection is idle for 20 seconds or longer, then Amazon S3 closes the connection and returns the 400 RequestTimeout error. To verify whether this is causing the error, perform a packet capture and check for any packet drops.