问题是偶发的,有的无从下手的感觉,感觉是网络问题。但OSS和ECS都是一个中心的。不知道如何优化了。求大神指点。
Caused by: com.aliyun.oss.ClientException: ConnectionTimeout
at com.aliyun.oss.common.utils.ExceptionFactory.createNetworkException(ExceptionFactory.java:68)
at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:67)
at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:121)
at com.aliyun.oss.common.comm.ServiceClient.sendRequest(ServiceClient.java:67)
at com.aliyun.oss.internal.OSSOperation.send(OSSOperation.java:89)
at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:130)
at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:108)
at com.aliyun.oss.internal.OSSObjectOperation.writeObjectInternal(OSSObjectOperation.java:574)
at com.aliyun.oss.internal.OSSObjectOperation.putObject(OSSObjectOperation.java:119)
at com.aliyun.oss.OSSClient.putObject(OSSClient.java:412)
at com.aliyun.oss.OSSClient.putObject(OSSClient.java:399)
at cn.***.framework.web.AbstractOSSFileUploadService.upload(AbstractOSSFileUploadService.java:321)
at cn.***.framework.web.AbstractOSSFileUploadService.upload(AbstractOSSFileUploadService.java:494)
at com.***.doctor.service.DoctorImage.uploadHeadIcon(DoctorImage.java:178)
... 36 more
Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to ***.oss-cn-beijing.aliyuncs.com:80 timed out
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
at org.apache.http.impl.client.Closeable(和谐)HttpClient.execute(Closeable(和谐)HttpClient.java:82)
at org.apache.http.impl.client.Closeable(和谐)HttpClient.execute(Closeable(和谐)HttpClient.java:107)
at org.apache.http.impl.client.Closeable(和谐)HttpClient.execute(Closeable(和谐)HttpClient.java:55)
at com.aliyun.oss.common.comm.DefaultServiceClient.sendRequestCore(DefaultServiceClient.java:64)
... 48 more
涉及公司的关键词统一用***代替了
上传用的代码。
protected SystemUploadFile upload(String fileName) {
SystemUploadFile suf;
try {
//获取表单文件字段的数据
Part part = ThreadLocalParameter.getThreadLocal().getRequest().getPart(formField);
if (part == null) {
return null;
}
//获取提交文件的名称
String uploadFileName = part.getSubmittedFileName();
if (uploadFileName == null || uploadFileName.isEmpty()) {
return null;
}
if (fileName.indexOf("/") == 0) {
fileName = fileName.replaceFirst("/", "");
}
if (uploadFileName.contains(".")) {
fileName += uploadFileName.substring(uploadFileName.lastIndexOf("."));
}
//拼接prefix
String filePath = oss_prefix + "/" + fileName;
InputStream in;
in = null;
try {
in = part.getInputStream();
// 创建上传Object的Metadata
ObjectMetadata meta = new ObjectMetadata();
// 必须设置ContentLength
meta.setContentLength(part.getSize());
// if(client==null){
// client = new OSSClient(oss_endpoint, access_id, access_key);
// }
// 上传Object.
PutObjectResult result = getClient().putObject(bucket, filePath, in, meta);
} catch (IOException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "上传文件失败", ex);
return null;
} finally {
if (in != null) {
in.close();
}
}
suf = new SystemUploadFile();
suf.setFilePath(fileName);
suf.setFileSize(part.getSize());
suf.setFileType(part.getContentType());
suf.setUploadTimeStamp(new Date());
} catch (IOException | ServletException ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "上传文件失败", ex);
return null;
}
return suf;
}
-------------------------
ping ***.oss-cn-beijing.aliyuncs.com
PING oss-cn-beijing.aliyuncs.com (182.92.18.4) 56(84) bytes of data.
64 bytes from 182.92.18.4: icmp_seq=1 ttl=60 time=0.178 ms
64 bytes from 182.92.18.4: icmp_seq=2 ttl=60 time=0.189 ms
64 bytes from 182.92.18.4: icmp_seq=3 ttl=60 time=0.168 ms
64 bytes from 182.92.18.4: icmp_seq=4 ttl=60 time=0.197 ms
64 bytes from 182.92.18.4: icmp_seq=5 ttl=60 time=0.169 ms
64 bytes from 182.92.18.4: icmp_seq=6 ttl=60 time=0.166 ms
64 bytes from 182.92.18.4: icmp_seq=7 ttl=60 time=0.160 ms
64 bytes from 182.92.18.4: icmp_seq=8 ttl=60 time=0.167 ms
64 bytes from 182.92.18.4: icmp_seq=9 ttl=60 time=0.173 ms
64 bytes from 182.92.18.4: icmp_seq=10 ttl=60 time=0.218 ms
64 bytes from 182.92.18.4: icmp_seq=11 ttl=60 time=0.179 ms
64 bytes from 182.92.18.4: icmp_seq=12 ttl=60 time=0.196 ms
64 bytes from 182.92.18.4: icmp_seq=13 ttl=60 time=0.169 ms
64 bytes from 182.92.18.4: icmp_seq=14 ttl=60 time=0.168 ms
64 bytes from 182.92.18.4: icmp_seq=15 ttl=60 time=0.184 ms
64 bytes from 182.92.18.4: icmp_seq=16 ttl=60 time=0.193 ms
64 bytes from 182.92.18.4: icmp_seq=17 ttl=60 time=0.221 ms
64 bytes from 182.92.18.4: icmp_seq=18 ttl=60 time=0.187 ms
64 bytes from 182.92.18.4: icmp_seq=19 ttl=60 time=0.170 ms
64 bytes from 182.92.18.4: icmp_seq=20 ttl=60 time=0.189 ms
64 bytes from 182.92.18.4: icmp_seq=21 ttl=60 time=0.187 ms
64 bytes from 182.92.18.4: icmp_seq=22 ttl=60 time=0.182 ms
64 bytes from 182.92.18.4: icmp_seq=23 ttl=60 time=0.198 ms
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。