Network exceptions usually happen because an incorrect endpoint is used to access Object Storage Service (OSS) or network connectivity on the client side is poor. This topic describes how to troubleshoot network exceptions in OSS.
Background information
If OSS returns a response to your request, the connectivity between your client and OSS is normal. This is true, even if the HTTP status code in the response is not 200. If an error is included in the response, use the request ID to troubleshoot the error in the Self-service Diagnostics Tool. For more information about how to obtain request IDs, see Obtain request IDs.
In this topic, network exceptions refer to issues that cause requests to be dropped before they are received by OSS. To determine whether a request is received by OSS, you can try to retrieve its request ID. If you can retrieve its ID, the request is received by OSS.
Connection refused
Causes
Your client and the OSS bucket do not reside in the same region. When you access an OSS bucket through the internal endpoint, the client and bucket must reside in the same region. For example, you can access a bucket in the China (Hangzhou) region from an Elastic Compute Service (ECS) instance in the same region by using the oss-cn-hangzhou-internal.aliyuncs.com endpoint. For more information about endpoints, see Regions and endpoints.
Your client is in the same region as the bucket, but the configurations of your client may cause network exceptions. For example, specific ports are closed on the client.
Solutions
Check whether the endpoint configured for your client is an internal endpoint (contains the word "internal"). If yes, switch the endpoint to a public endpoint. If your request is successfully sent through the public endpoint, your client does not support the use of internal endpoints.
Use the ping command to test the network connectivity between your client and the public endpoint for the region in which the bucket is located. For example, you can use
ping oss-cn-hangzhou.aliyuncs.comto test the network connectivity between your client and OSS in the China (Hangzhou) region. If the ping fails, use the telnet command to test whether port 80 or 443 is available.
ConnectionTimeOut
Causes
Your network is managed by an edge node of your Internet service provider (ISP), and connectivity issues cause requests to be dropped.
The upload of large objects is not completed within the configured timeout period.
The configured timeout period is too short.
Solutions
Enable CDN acceleration and use CDN POPs to accelerate data transfers. This reduces the impact of the ISP network on data transfer quality for mobile phones and PCs.
Use multipart upload or resumable upload when you want to upload large objects, and make sure that each part is smaller than 1 MB in size. For more information, see Multipart upload, Resumable upload in Java, and Resumable upload in Python.
Configure a longer timeout period and enable retries on failed uploads. For sample code in various programming languages, see Overview.
For more information about how to troubleshoot connection timeouts, see Network connection timeout handling.
Socket timeout or Socket closed
Cause
The connection has timed out.
Solution
Increase the timeout period. For example, you can use ClientConfiguration.setSocketTimeout in OSS SDK for Java to set the timeout period for data transmission at the socket layer. For sample code in various programming languages, see Overview.
Connection reset
Causes
The network connection on the client side is abnormal.
An incorrect endpoint is specified in your code.
The bucket that you want to access is moved into the sandbox due to attacks or content compliance violations.
The domain name of the bucket is hijacked.
Solutions
Check whether the network connection on the client side is normal.
Use the ping command to test the network connectivity between the client and the endpoint for the region in which the bucket is located, or use the Alibaba Cloud DNS diagnosis tool to check your network connection. If your network connection is abnormal, fix the connection and retry your request.
Check the endpoint in your code.
Check whether the client network works as expected. Ping the OSS endpoint of the region where the OSS resources that you want to access reside on the device on which the error occurred. For more information about endpoints, see Regions and endpoints.
NoteThe endpoint specified in the code must be prefixed with HTTP or HTTPS, such as https://oss-cn-hangzhou.aliyuncs.com.
For sample code in various programming languages, see Overview.
Check whether the bucket is moved into the sandbox.
If the bucket is moved into the sandbox, the bucket can still respond to requests, but the service quality is degraded. For more information, see OSS sandbox.
Capture packets for troubleshooting.
If the problem persists, use the Wireshark tool to capture packets and contact OSS technical support.