Problem description
When you use the OSS Java SDK, an error message similar to the following is reported.
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)Cause
The client and OSS are not in the internal network of the same region, so you cannot use the endpoints of the internal network. You need to use the endpoints of the public network.
Although the client and OSS are in the same area, the client may have some special restrictions, such as the port is not open.
Solutions
We recommend that you use the ping command on the client to test the endpoint address of the Internet and the telnet command to test whether port 80/443 is normal. If the test is normal, configure the OSS Java SDK as follows.
OSSClient client = new OSSClient(OSS_ENDPOINT,ACCESS_ID, ACCESS_KEY); of private static final String OSS_ENDPOINT = "http://oss-cn-hangzhou.aliyuncs.com/"; Note: This topic uses the http://oss-cn-hangzhou.aliyuncs.com/ address in the Hangzhou region as an example. For other regions, modify the endpoint based on the details of the domain name and data center. For more information, see Access domain name and data center.
Applicable scope
Object Storage Service (OSS)