c# - TTransportException "Cannot read, Remote side has closed"

标签 c# thrift

在我用 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);
        }

如有任何帮助,我们将不胜感激。

最佳答案

尝试使用,

client.InputProtocol.Transport.Open();

代替,

transport.Open();

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

关于c# - TTransportException "Cannot read, Remote side has closed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13503601/

相关文章:

python - 我的 thrift ./configure 不构建 python 库

c# - WPF 消息处理不尊重使用 RegisterHotKey 处理的参数

c# - .NET 文件锁定问题

c# - 允许用户在 FullCalendar 资源 View 的每个单元格中仅添加一个事件

java - 如何使用thrift生成器作为maven依赖(如何避免引用.exe文件)?

version - 如何在版本控制中管理thrift源文件?

c++ - 本地主机上的 TServerSocket 生成异常

c# - 如何以编程方式为单个应用程序设置多个身份验证 cookie

c# - 在尝试访问控制的 cs 页面中使用 'this' 时出错

python - python中子命名空间的节俭使用