什么是“java.net.NoRouteToHostException:无法分配请求的地址”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38721830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is "java.net.NoRouteToHostException: Cannot assign requested address"?
提问by Jason
That's it. I have never seen before. I am trying Tcp Holepunching.
而已。我以前从未见过。我正在尝试 Tcp 打孔。
One Client should be both client and server(for other client).
一个客户端应该既是客户端又是服务器(对于其他客户端)。
I got this Exception. Is there anyone who know about this problem?
我得到了这个异常。有没有人知道这个问题?
java.net.NoRouteToHostException: Cannot assign requested address
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at com.temp.TcpSocketClient.run(TcpSocketClient.java:563)
at java.lang.Thread.run(Thread.java:745)
回答by u6588371
hey can you check you request is use keep-Alive option? If you are doing a stress test, please try turning it off.
嘿,你能检查一下你的请求是使用 keep-Alive 选项吗?如果您正在进行压力测试,请尝试将其关闭。
回答by jitendra varshney
Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the remote host cannot be reached because of an intervening firewall, or if an intermediate router is down. Read this Documnet
尝试将套接字连接到远程地址和端口时发生错误的信号。通常,由于防火墙的介入或中间路由器关闭,无法访问远程主机。阅读此文档
https://docs.oracle.com/javase/7/docs/api/java/net/NoRouteToHostException.html
https://docs.oracle.com/javase/7/docs/api/java/net/NoRouteToHostException.html
you can also go through these answers
你也可以通过这些答案