gpt4 book ai didi

java - 将查询重定向到 google 并在 Json 对象中获取结果时出现 UnknownHostException

转载 作者:行者123 更新时间:2023-12-02 08:38:16 26 4
gpt4 key购买 nike

Loading classifier from D:\PROJECT\classifiers\NERDemo\classifiers\ner-eng-ie.crf-3-all2008.ser.gz ... done [2.0 sec].
Original Query was riot in India.
Parsing Queries and expanding tokens from the Ontologies..
{locations=[India], events=[riot]}
Search query is null
Something went wrong...

java.net.UnknownHostException: ajax.googleapis.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at org.girs2.SearchHandler.makeQuery(SearchHandler.java:35)
at org.girs2.GIRS.search(GIRS.java:37)
at org.girs2.GIRS.main(GIRS.java:62)
Exception in thread "main" java.lang.NullPointerException
at org.girs2.GIRS.search(GIRS.java:44)
at org.girs2.GIRS.main(GIRS.java:62)

最佳答案

看起来您可能已经或曾经发生过 DNS 查找失败。这告诉你发生了什么:

java.net.UnknownHostException: ajax.googleapis.com

如果您总是遇到此异常,并且可以通过名称访问此主机,那么我不知道这可能是什么,但很可能这是暂时的 DNS 故障。

当你遇到这个异常时你应该做什么?好吧,如果该地址是您完全期望能够到达的地址(例如这个地址),那么当您捕获异常时,您会 hibernate 一段时间(可能 10 或 15 秒,甚至可能 30 或 60 秒)秒,具体取决于您的应用程序的需求),然后重试。

如果多次重试后——不要永远重试! -- 您仍然无法访问该网站,然后记录合理的投诉或以其他方式投诉您无法访问该网站并退出您的应用程序。

当 DNS 失败时,除了放弃或等待并重试之外,您无能为力。

关于java - 将查询重定向到 google 并在 Json 对象中获取结果时出现 UnknownHostException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/703879/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com