Java UnknownHostException 何时以及为何?

发布于 2024-12-13 09:12:20 字数 1898 浏览 0 评论 0原文

我正在尝试从处理草图发布到网站。 (处理基本上是在一个奇特的环境中运行的Java)。我正在使用这个库: http://libraries.seltar.org/postToWeb/ 但我不不知道这是否有什么不同。从下面的堆栈跟踪可以看出,这只是 Java 标准库的包装器。

无论如何,重要的一点是主机“mysite.com”已启动并正在运行。我是从浏览器看到的。但是当我尝试从 Java 发布到它时,我只是出现 UnknownHostException。

鉴于该网站已启动。这还可能意味着什么?

该程序当前正在处理环境中运行。大概是作为一个小程序。

java.net.UnknownHostException: mysite.com
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
    at sun.net.www.http.HttpClient.New(HttpClient.java:306)
    at sun.net.www.http.HttpClient.New(HttpClient.java:323)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1014)
    at org.seltar.Bytes2Web.PostToWeb._post(PostToWeb.java:90)
    at org.seltar.Bytes2Web.ByteToWeb.post(ByteToWeb.java:66)
    at experimentPostToWeb.keyPressed(experimentPostToWeb.java:35)
    at processing.core.PApplet.handleKeyEvent(Unknown Source)
    at processing.core.PApplet.dequeueKeyEvents(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)

I'm trying to post to a website from a Processing Sketch. (Processing is basically Java running in a fancy environment). I'm using this library : http://libraries.seltar.org/postToWeb/ but I don't know if that makes a difference. You can see from the stack trace below that this is just a wrapper for the Java standard library.

Anyway, the important point is that the host "mysite.com" is up and running. I am seeing it from the browser. But when I try to post to it from Java I just get the UnknownHostException appearing.

Given that the site is up. What else might this mean?

The program is currently running inside the Processing environment. Presumably as an Applet.

java.net.UnknownHostException: mysite.com
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
    at sun.net.www.http.HttpClient.New(HttpClient.java:306)
    at sun.net.www.http.HttpClient.New(HttpClient.java:323)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1014)
    at org.seltar.Bytes2Web.PostToWeb._post(PostToWeb.java:90)
    at org.seltar.Bytes2Web.ByteToWeb.post(ByteToWeb.java:66)
    at experimentPostToWeb.keyPressed(experimentPostToWeb.java:35)
    at processing.core.PApplet.handleKeyEvent(Unknown Source)
    at processing.core.PApplet.dequeueKeyEvents(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南烟 2024-12-20 09:12:20

代理问题。您的 DNS 查找失败是因为在 LAN 内没有向该网站注册任何内容,并且 ProxySelector 未使用代理来访问互联网。

Proxy problems. Your DNS lookup failure occurs because within the LAN there is nothing registered to that website and the ProxySelector is not using a proxy to reach out to the internet.

残疾 2024-12-20 09:12:20

您可能只使用 link() 处理方法
http://processing.org/reference/link_.html
这样您就可以验证处理实际上正在查看您的页面,然后您可以尝试发布到该页面。

You could probably just use the link() method of processing
http://processing.org/reference/link_.html
That way you can verify that processing is actually seeing your page, and from there on you can try to post to it.

风吹过旳痕迹 2024-12-20 09:12:20

您可以将 -Djava.rmi.server.hostname= -Dremoting.bind_by_host=false 添加到服务器上的运行脚本中

You can add -Djava.rmi.server.hostname= -Dremoting.bind_by_host=false to the run script at the server

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文