Thrift 客户端无法连接 [英] Thrift Client can't connect

查看:72
本文介绍了Thrift 客户端无法连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在同一台计算机上运行的 thrift 服务器和客户端,但是当我在不同的计算机上运行客户端时(使用服务器计算机的 IP),客户端无法连接.两台电脑都是linux.有任何想法吗?

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?

如果我在我的服务器计算机上使用 sudo netstat -tulpn | 检查某些 IP 上的活动grep [ip]:[port],我得到:

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 -> 什么都没有

172.18.18.106:9090 -> nothing

:9090 -> tcp 0 0 0.0.0.0:9090 0.0.0.0:* LISTEN 10642/server

有没有办法把 0.0.0.0 改成我的 ip?

Is there a way to change 0.0.0.0 to my ip?

推荐答案

最近我遇到了与 apache hbase.2.1.2 类似的问题.我已经设置了 hbase 并启动了 thrift 服务器.它打开了端口 9090 和 9095.我可以在本地连接到它们,但不能远程连接.由于我可以远程 telnet 两个端口,因此解决了防火墙问题.我发现问题出在超时设置中.显然,您创建的默认 TSocket 似乎在本地设置中具有非常有限的超时.但是,对于远程连接,您需要在创建 TSocket 时增加超时时间.

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)

这篇关于Thrift 客户端无法连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆