在eclipse中运行阿里云sms短信服务时,发送与接收信息运行正常,打包后部署到tomcat服务器上后,启动tomcat服务器后,服务器报如下错误,一直运行不起来,不知道啥原因。
08:43:38.175 [PullMessageTask-thread] ERROR c.a.m.t.DefaultAlicomMessagePuller - PullMessageTask_execute_error,messageType:SmsUp,queueName:Alicom-Queue-XXXXXXXXXXXXXX-SmsUp
com.aliyuncs.exceptions.ClientException: SDK.ServerUnreachable : Server unreachable: java.net.UnknownHostException: dybaseapi.aliyuncs.com
at com.aliyuncs.DefaultAcsClient.doAction(DefaultAcsClient.java:207) ~[aliyun-java-sdk-core-3.2.2.jar:na]
at com.aliyuncs.DefaultAcsClient.doAction(DefaultAcsClient.java:152) ~[aliyun-java-sdk-core-3.2.2.jar:na]
at com.aliyuncs.DefaultAcsClient.doAction(DefaultAcsClient.java:60) ~[aliyun-java-sdk-core-3.2.2.jar:na]
at com.aliyuncs.DefaultAcsClient.getAcsResponse(DefaultAcsClient.java:104) ~[aliyun-java-sdk-core-3.2.2.jar:na]
at com.alicom.mns.tools.TokenGetterForAlicom.getTokenFromRemote(TokenGetterForAlicom.java:63) ~[receive-2017.8.jar:na]
at com.alicom.mns.tools.TokenGetterForAlicom.getTokenByMessageType(TokenGetterForAlicom.java:92) ~[receive-2017.8.jar:na]
at com.alicom.mns.tools.DefaultAlicomMessagePuller$PullMessageTask.run(DefaultAlicomMessagePuller.java:31) ~[receive-2017.8.jar:na]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]
08:43:38.175 [PullMessageTask-thread] ERROR c.a.m.t.DefaultAlicomMessagePuller - PullMessageTask_execute_error,messageType:SmsReport,queueName:Alicom-Queue-XXXXXXXXXXXXXX-SmsReport
com.aliyuncs.exceptions.ClientException: SDK.ServerUnreachable : Server unreachable: java.net.UnknownHostException: dybaseapi.aliyuncs.com
at com.aliyuncs.DefaultAcsClient.doAction(DefaultAcsClient.java:207) ~[aliyun-java-sdk-core-3.2.2.jar:na]
at com.aliyuncs.DefaultAcsClient.doAction(DefaultAcsClient.java:152) ~[aliyun-java-sdk-core-3.2.2.jar:na]
at com.aliyuncs.DefaultAcsClient.doAction(DefaultAcsClient.java:60) ~[aliyun-java-sdk-core-3.2.2.jar:na]
at com.aliyuncs.DefaultAcsClient.getAcsResponse(DefaultAcsClient.java:104) ~[aliyun-java-sdk-core-3.2.2.jar:na]
at com.alicom.mns.tools.TokenGetterForAlicom.getTokenFromRemote(TokenGetterForAlicom.java:63) ~[receive-2017.8.jar:na]
at com.alicom.mns.tools.TokenGetterForAlicom.getTokenByMessageType(TokenGetterForAlicom.java:92) ~[receive-2017.8.jar:na]
at com.alicom.mns.tools.DefaultAlicomMessagePuller$PullMessageTask.run(DefaultAlicomMessagePuller.java:31) ~[receive-2017.8.jar:na]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]
public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile("default", "<accessKeyId>", "<accessSecret>");
IAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
//request.setProtocol(ProtocolType.HTTPS);
request.setMethod(MethodType.POST);
request.setDomain("dysmsapi.aliyuncs.com");
request.setVersion("2017-05-25");
request.setAction("SendSms");
try {
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
}
这是官方的例子,你可以检查下你配置的各个参数,你抛的异常是服务器无法访问,另外推荐你使用我的工具,方便你的使用点击前往
一.先确定在服务器可否正常打开
命令行 wget http://localhost:8080检查 或浏览器 http://localhost:8080检查
二.如果上面没问题进入阿里云控制台:
步骤:
1.登陆阿里云
2.进入安全组
“控制台” -> “云服务器 ECS” -> 选择云服务器 -> “更多” -> “安全组配置”
3.配置规则
“配置规则” -> “添加安全组规则”
4.配置8080端口
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。