在python中Thrift TTransportException
问题描述:
我在尝试使用thrift在python上执行RPC时出现奇怪的错误。我在网上发现了类似的问题,但没有一个真正适用于我的情况。在python中Thrift TTransportException
这里是我得到
No handlers could be found for logger "thrift.transport.TSocket"
Traceback (most recent call last):
File "experiment.py", line 71, in <module>
transport.open()
File "/usr/local/lib/python2.7/dist-packages/thrift/transport/TTransport.py", line 152, in open
return self.__trans.open()
File "/usr/local/lib/python2.7/dist-packages/thrift/transport/TSocket.py", line 113, in open
raise TTransportException(TTransportException.NOT_OPEN, msg)
thrift.transport.TTransport.TTransportException: Could not connect to any of [('192.168.178.44', 9000)]
以下是我认为的错误,产生它的代码。
TECS_SERVER_IP = "192.168.178.44"
TECS_SERVER_PORT = 9000
transport = TSocket.TSocket(TECS_SERVER_IP, TECS_SERVER_PORT)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = TTSService.Client(protocol)
transport.open()
发生这种情况时,我试图传达给另一台机器上,所以我试图用IP“127.0.0.1”和它的作品。但是,使用应引用同一台计算机的本地主机“192.168.178.44”的IP也会产生错误。 对我来说,它似乎不能解决IP地址由于某种原因... 任何想法是什么导致这个问题,以及如何解决它?
我使用Python 2.7.12,节俭0.9.3和Ubuntu 16.04,但我也得到了错误的Windows 10
这是我的节俭服务的启动方式
handler = TTSHandler()
handler.__init__()
transport = TSocket.TServerSocket(host='localhost', port=9000)
processor = TTSService.Processor(handler)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
server.serve()
您的TServer如何启动? – georgexsh
@georgexsh检查我的新编辑 – Girauder