2015-02-24 205 views
0

我正尝试从Windows上的Eclise RSE远程计算机(Ubuntu)上使用Hbase,thrift和python。一切工作正常,但是当我试图连接到本地主机我得到一个错误:Eclipse RSE连接到远程计算机上的本地主机

thrift.transport.TTransport.TTransportException: Could not connect to localhost:9090 

如果我在远程机器上运行通过SSH终端这段代码,它完美的作品。

这里是我的代码:

#!/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() 

回答

0

你知道什么是本地主机的手段?它意味着你正在运行命令的机器。例如。如果我在我的PC上的浏览器中输入http://localhost:8080/,那么它会调用运行在我的机器上的端口8080上的服务器。

如果您尝试在同一个盒子上连接到本地主机,我确定您的连接正常工作。如果从不同的机器连接,则需要知道要连接的盒子的IP地址或主机名。

相关问题