赞
踩
配置钉钉机器人时,我发现服务器连接oapi.dingtalk.com接口连接不上去报错如下
java.net.UnknownHostException: oapi.dingtalk.com
ERROR: 钉钉机器人发生错误:java.net.UnknownHostException: oapi.dingtalk.com at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:607) at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:288) at sun.net.NetworkClient.doConnect(NetworkClient.java:175) at sun.net.www.http.HttpClient.openServer(HttpClient.java:463) at sun.net.www.http.HttpClient.openServer(HttpClient.java:558) at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264) at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:203) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1205) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:189) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1340) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1315) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:264) at io.jenkins.plugins.sdk.HttpRequest.request(HttpRequest.java:75) at io.jenkins.plugins.sdk.DingTalkSender.call(DingTalkSender.java:119) at io.jenkins.plugins.sdk.DingTalkSender.sendActionCard(DingTalkSender.java:98) at io.jenkins.plugins.service.impl.DingTalkServiceImpl.send(DingTalkServiceImpl.java:60) at io.jenkins.plugins.DingTalkRunListener.send(DingTalkRunListener.java:248) at io.jenkins.plugins.DingTalkRunListener.onCompleted(DingTalkRunListener.java:62) at io.jenkins.plugins.DingTalkRunListener.onCompleted(DingTalkRunListener.java:42) at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:209) at hudson.model.Run.execute(Run.java:1957) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:100) at hudson.model.Executor.run(Executor.java:432)
原因是 调用钉钉服务很慢,偶尔会报java.net.UnknownHostException: oapi.dingtalk.com
ping 一下 oapi.dingtalk.com
得到IP地址 106.11.43.160
[root@k8s-master01 ~]# ping oapi.dingtalk.com
PING cname.dingtalk.com.gds.alibabadns.com (106.11.43.160) 56(84) bytes of data.
64 bytes from 106.11.43.160 (106.11.43.160): icmp_seq=1 ttl=83 time=7.49 ms
64 bytes from 106.11.43.160 (106.11.43.160): icmp_seq=2 ttl=83 time=7.34 ms
64 bytes from 106.11.43.160 (106.11.43.160): icmp_seq=3 ttl=83 time=7.32 ms
^C
--- cname.dingtalk.com.gds.alibabadns.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 11ms
rtt min/avg/max/mdev = 7.315/7.414/7.492/0.115 ms
把 106.11.43.160 oapi.dingtalk.com 配置到hosts里面
vim /etc/hosts
106.11.43.160 oapi.dingtalk.com
CSDN_码404:钉钉接口报错java.net.UnknownHostException: oapi.dingtalk.com_无法访问oapi.dingtalk.com
https://www.code404.icu/898.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。