hprose / hprose-java

Hprose is a cross-language RPC. This project is Hprose 2.0 for Java
MIT License
550 stars 187 forks source link

服务器在NAT后,无法使用。 #20

Closed ghost closed 8 years ago

ghost commented 8 years ago

版本1.5.2 h_for_java8 运行包中带的TCPHello_的例子可以运行。

  1. 在本地,如果helloServer和helloClient中的ip任何一个不使用localhost,比如其中一个使用(本机ip)192.168..,另一个使用localhost。连接不成功。 同时使用192.168._.*是可以的。 server和client中的地址必须写成一模一样才能用吗? 2.server 在远程服务器上,服务器是通过nat分配的公网ip,在服务器本机ping自己的公网ip是ping到的。 所以server使用公网ip会出错。 如果写成它的内网ip,就会重复了第1个问题,客户端写的是公网ip,服务端是自己的内网ip。连接失败。
sidyhe commented 8 years ago

你说的这个有点像ALICLOUD的虚拟主机 有两个网卡, 一个内网一个外网 那么在公网IP上开启服务就可以了(或者localhost/0.0.0.0?) 客户端直接连那个公网IP即可

ghost commented 8 years ago

服务器只用了一个网卡,通过NAT映射的,用公网ip启动的时候就会有问题,并且一个写localhost,一个写ip,在本地测试的时候都会出错。

andot commented 8 years ago

监听 0.0.0.0 就可以了。