Problem description
When you use the OSS Java software development kit (SDK), an error message similar to the following is returned.
Connection to http://buname.oss-cn-hangzhou-internal.aliyuncs.com refused
[RequestId]: Unknown
at com.aliyun.oss.common.utils.ExceptionFactory.createNetworkException(ExceptionFactory.java:31)
at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:57)
at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:191)
at com.aliyun.oss.common.comm.ServiceClient.sendRequest(ServiceClient.java:151)
at com.aliyun.oss.internal.OSSOperation.send(OSSOperation.java:71)
at com.aliyun.oss.internal.OSSObjectOperation.putObject(OSSObjectOperation.java:92)
at com.aliyun.oss.OSSClient.putObject(OSSClient.java:394)
at osscs1.OSSPutObjectSample.uploadFile(OSSPutObjectSample.java:82)
at osscs1.OSSPutObjectSample.main(OSSPutObjectSample.java:46)
Problem causes
-
The client and OSS are not in the private network of the same region. Therefore, the public endpoint must be used instead of the internal endpoint.
-
Even if the client and OSS are in the same region, the client may have restrictions, such as closed ports.
Solution
On the client, use the `ping` command to test the public endpoint. Use the `telnet` command to test if ports 80 and 443 are open. If these tests pass, configure the OSS Java SDK as follows.
private static final String OSS_ENDPOINT = "http://oss-cn-hangzhou.aliyuncs.com/";
OSSClient client = new OSSClient(OSS_ENDPOINT,ACCESS_ID, ACCESS_KEY);
This topic uses the Hangzhou region and the http://oss-cn-hangzhou.aliyuncs.com/ endpoint as an example. For other regions, change the endpoint accordingly. For more information, see Endpoints and data centers.
Applies to
-
Object Storage Service (OSS)