美文网首页
偶发java.net.UnknownHostException

偶发java.net.UnknownHostException

作者: 放开好人 | 来源:发表于2021-07-06 09:32 被阅读0次

    一、问题描述

    现通过公网与某机构联调测试,环境、服务、网络都未变动的情况下,偶发性出现域名解析错误问题。

    java.net.UnknownHostException: open-test.nbcb.com.cn
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
        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:191)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:162)
    

    二、排查分析

    UnknownHostException-域名解析异常。

    ping域名正常

    [root@osb39 info]# ping open-test.nbcb.com.cn
    PING open-test.nbcb.com.cn (1x3.1x6.1x8.8) 56(84) bytes of data.
    

    telnet端口正常

    [root@osb39 info]# telnet open-test.nbcb.com.cn 443
    Trying 1x3.1x6.1x8.8...
    Connected to open-test.nbcb.com.cn.
    Escape character is '^]'.
    

    curl偶发出现解析失败

    image.png

    三、问题解决

    一般来讲,域名解析失败必然和DNS有关。
    联系网络同事修改DNS(cat /etc/resolv.conf)配置后发现问题依旧存在。
    后直接写死地址到hosts配置中,

    vi /etc/hosts
    1x3.1x6.1x8.8 open-test.nbcb.com.cn
    

    偶发解析异常的根本原因暂未查明。本篇主要记录排查过程及解决方式。

    相关文章

      网友评论

          本文标题:偶发java.net.UnknownHostException

          本文链接:https://www.haomeiwen.com/subject/kxnwultx.html