【问题标题】:TTransportException "Cannot read, Remote side has closed"TTransportException“无法读取,远程端已关闭”
【发布时间】:2012-11-10 07:32:53
【问题描述】:

在我用 C# 编写的客户端中出现此错误。我的服务器在 python 中。这是我第一个使用 Thrift 的测试程序。看起来我的 python 服务器正在运行。这是我的客户代码。我在调用“Client.add(2,3)”时收到此错误

static void Main(string[] args)
    {
        try
        {
            var socket = new TSocket("localhost", 9089);
            var transport = new TBufferedTransport(socket);
            var protocol = new TBinaryProtocol(transport);
            var client = new CalculatorService.Client(protocol);
            transport.Open();
            if (transport.IsOpen)
            {
                //I am seeing this message
                Console.WriteLine("server is open for business");                    
            }
            Console.WriteLine(client.add(2, 3)); //this is the line that gives me the error
            transport.Close();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

任何帮助将不胜感激。

【问题讨论】:

  • 服务器端的日志是什么,有没有接到调用?你在两边都使用二进制协议吗?
  • 你解决过这个问题吗?
  • 我也想知道 :)

标签: c# thrift


【解决方案1】:

尝试使用,

client.InputProtocol.Transport.Open();

而不是,

transport.Open();

顺便说一句,我的服务器是基于 Java 的

【讨论】:

  • 想解释否决票?这是一个对我有用的解决方案,这就是我将其作为答案的原因。
  • 因编辑而被删除。在 .NET 领域,此更改对操作没有影响,因为 client.InputProtocol.Transporttransport 指向同一个对象。
猜你喜欢
  • 2013-08-17
  • 1970-01-01
  • 2015-07-30
  • 2020-05-19
  • 1970-01-01
  • 1970-01-01
  • 2011-11-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多