【发布时间】:2018-10-23 23:09:07
【问题描述】:
我正在我的机器上运行 Facebook Thrift 服务。我使用了一个示例代码来展示它的工作原理:
import asyncio
from fbnet.command_runner.thrift_client import AsyncioThriftClient
# Import FCR Thrift Types
from fbnet.command_runner_asyncio.CommandRunner import ttypes as fcr_ttypes
# Import FCR Service Client
from fbnet.command_runner_asyncio.CommandRunner.Command import Client as FcrClient
import getpass
# Device Information
hostname = 'my_vm'
username = 'root'
password = getpass.getpass('%s Password: ' % username)
# Destination device
device = fcr_ttypes.Device(hostname=hostname, username=username, password=password)
async def run(cmd, device):
async with AsyncioThriftClient(FcrClient, 'x.x.x.x',22 ) as client:
res = await client.run(cmd, device)
# type of res is `struct CommandResult`
print(res.output)
loop = asyncio.get_event_loop()
loop.run_until_complete(run('uname -a', device))
但是我收到以下错误:
帧大小 1397966893 对于 THeaderProtocol Traceback 来说太大(大多数 最近通话最后):
文件“pgm1.py”,第 28 行,在 loop.run_until_complete(run('uname -a', device))
文件“/usr/local/lib/python3.6/asyncio/base_events.py”,第 467 行,在 run_until_complete 返回 future.result()
运行中的文件“pgm1.py”,第 23 行 res = await client.run(cmd, device) thrift.transport.TTransport.TTransportException: 连接关闭
关于如何纠正这个问题的任何想法?
【问题讨论】:
-
1397966893 = 0x5353482D的奇怪值从何而来?一些未初始化的变量? -
我对thrift一无所知,但是0x5353482D是四个字符“SSH-”,这恰好是ssh服务器连接到它时发送的第一个数据。我的猜测是您正试图在连接到 ssh 服务器的原始 TCP 套接字上启动 thrift。
标签: python facebook ssh thrift