[英]Eclipse RSE connect to a localhost on a remote machine
I'm trying to work with Hbase, thrift, and python on a remote machine(Ubuntu) from Eclise RSE on windows. 我正试图在Windows上的Eclise RSE远程机器(Ubuntu)上使用Hbase,thrift和python。 Everything is working fine but when I'm trying to connect to the localhost I get an error:
一切正常,但当我尝试连接到localhost时,我收到一个错误:
thrift.transport.TTransport.TTransportException: Could not connect to localhost:9090
If I run this code via ssh terminal on a remote machine, it works perfectly. 如果我通过远程机器上的ssh终端运行此代码,它可以正常工作。
Here is my code: 这是我的代码:
#!/usr/bin/env python
import sys, glob
sys.path.append('gen-py')
sys.path.insert(0, glob.glob('lib/py/build/lib.*')[0])
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from hbase import Hbase
# Connect to HBase Thrift server
transport = TTransport.TBufferedTransport(TSocket.TSocket('localhost', 9090))
protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
# Create and open the client connection
client = Hbase.Client(protocol)
transport.open()
tables = client.getTableNames()
print(tables)
# Do Something
transport.close()
Do you know what localhost means? 你知道localhost的意思吗? It means the machine you're running the command on.
它表示您正在运行命令的计算机。 Eg if I type http://localhost:8080/ in a browser on my PC then it will call the server running on port 8080 on MY machine.
例如,如果我在我的PC上的浏览器中输入http:// localhost:8080 /那么它将调用在我的机器上的端口8080上运行的服务器。
I'm sure your connection worked fine if you tried connecting to localhost while on the same box. 如果您尝试在同一个盒子上连接到localhost,我确定您的连接正常。 If connecting from a different machine then you'll need to know the IP address or the hostname of the box you're connecting to.
如果从另一台计算机连接,则需要知道要连接的盒子的IP地址或主机名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.