当前位置:   article > 正文

钉钉接口报错java.net.UnknownHostException: oapi.dingtalk.com_无法访问oapi.dingtalk.com_com.taobao.api.apiexception: java.net.unknownhoste

com.taobao.api.apiexception: java.net.unknownhostexception: oapi.dingtalk.co

钉钉接口报错java.net.UnknownHostException: oapi.dingtalk.com_无法访问oapi.dingtalk.com

简述


配置钉钉机器人时,我发现服务器连接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)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

解决方法


原因是 调用钉钉服务很慢,偶尔会报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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

把 106.11.43.160 oapi.dingtalk.com 配置到hosts里面

vim /etc/hosts
106.11.43.160 oapi.dingtalk.com
  • 1
  • 2

CSDN_码404:钉钉接口报错java.net.UnknownHostException: oapi.dingtalk.com_无法访问oapi.dingtalk.com

https://www.code404.icu/898.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/386087
推荐阅读
相关标签
  

闽ICP备14008679号