[英]Netty server remote connection
Netty server, Fedora. Netty服务器,Fedora。 I just can't connect to the server from remote host and no listening socket is displayed via netstat
util. 我只是无法从远程主机连接到服务器,并且没有通过netstat
util显示侦听套接字。 However I can establish the connection running client and server on the same machine. 但是,我可以在同一台计算机上建立运行客户端和服务器的连接。 That's simply like that: 就像这样:
port = System.getProperty(PORT_PROPERTY);
Preconditions.checkNotNull(port, "Network error, port property is not set");
hostAddress = new InetSocketAddress(Integer.valueOf(port));
...
serverChannel = bootstrap.bind(hostAddress);
I've tried initializing hostAddress
with the port only, localhost IP, 0.0.0.0 IP, and IP of my network. 我尝试仅使用端口,本地主机IP,0.0.0.0 IP和网络IP初始化hostAddress
。 Nothing helps. 没有任何帮助。 What could be the root of problem? 问题的根源可能是什么?
Here's some suggestions that should help disagnosing the problem: 以下是一些有助于诊断问题的建议:
new InetSocketAddress("0.0.0.0", Integer.valueOf(port))
since this will ensure you bind to all interfaces. 因为这将确保您绑定到所有接口。
Invoke the JVM with -Djava.net.preferIPv4Stack=true to force the JVM into IPV4. 使用-Djava.net.preferIPv4Stack = true调用JVM,以强制JVM进入IPV4。 I have found it easier to muck with these issues when in IPV4 since is it less complicated than V6. 我发现在IPV4中更容易处理这些问题,因为它不如V6复杂。
Get the PID of the JVM and then issue a netstat like this: 获取JVM的PID ,然后发出netstat,如下所示:
sudo netstat -ap --numeric-ports | grep <PID>
This should display all sockets for your JVM instance. 这应该显示您的JVM实例的所有套接字。 (Please post this output if you're still not able to connect remotely. Also post the output of ifconfig ) (如果您仍然不能远程连接,请发布此输出。还要发布ifconfig的输出)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.