【问题标题】:Eclipse RSE connect to a localhost on a remote machineEclipse RSE 连接到远程机器上的 localhost
【发布时间】:2015-02-24 10:02:29
【问题描述】:

我正在尝试在 Windows 上的 Eclise RSE 的远程机器 (Ubuntu) 上使用 Hbase、thrift 和 python。一切正常,但是当我尝试连接到 localhost 时出现错误:

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() 

【问题讨论】:

    标签: python eclipse hbase thrift eclipse-rse


    【解决方案1】:

    你知道本地主机是什么意思吗?这意味着您正在运行命令的机器。例如。如果我在 PC 上的浏览​​器中键入 http://localhost:8080/,它将调用在我机器上的 8080 端口上运行的服务器。

    如果您尝试在同一个机器上连接到 localhost,我相信您的连接工作正常。如果从另一台机器连接,那么您需要知道要连接的机器的 IP 地址或主机名。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多