问题
I have a thrift server and client that work when running on the same computer, but when I run the client on a different computer (using the IP of the server computer), the client can't connect. Both computers are linux. Any ideas?
EDIT: if I go on my server computer and check activity on certain IPs using sudo netstat -tulpn | grep [ip]:[port]
, I get:
172.18.18.106:9090 -> nothing
:9090 -> tcp 0 0 0.0.0.0:9090 0.0.0.0:* LISTEN 10642/server
Is there a way to change 0.0.0.0 to my ip?
回答1:
Yes, sure. You should bind your Thrift server with the IP of your server computer.
Another solution is checking if any firewall rules block port 9090 from accessing from outside network. You should do a telnet from your client computer:
telnet 172.18.18.106 9090
If it can connect, you're done.
回答2:
Offlately i got into similar issue with apache hbase.2.1.2. I had setup hbase and started thrift server. It opened port 9090 and 9095. I can connect to them locally but not remotely. As i can telnet both ports remotely, firewall issues are ironed out. I found the issue to be in timeout settings. Apparently it seems that the default TSocket which you create has very limited timeout which works in local settings. However for connecting remotely you need to increase the timeout while creating the TSocket.
TSocket socket = new TSocket(serverHostName, port, 10000)
来源:https://stackoverflow.com/questions/17733408/thrift-client-cant-connect