Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 c语言中的Apache Thrift客户端运行时问题#_C# 4.0_Thread Safety_Rpc_Thrift_Thrift Protocol - Fatal编程技术网

C# 4.0 c语言中的Apache Thrift客户端运行时问题#

C# 4.0 c语言中的Apache Thrift客户端运行时问题#,c#-4.0,thread-safety,rpc,thrift,thrift-protocol,C# 4.0,Thread Safety,Rpc,Thrift,Thrift Protocol,我正在开发一个用C#编写的客户机-服务器应用程序,它是使用Apache THRIFT RPC框架构建的 我们已经创建了几个带有服务定义的IDL文件(.thrift文件)。这些服务已经在服务器中实现,并且正在从客户端调用 下面给出了IDL文件中结构和服务定义的示例 结构视图列{ 1: string ColumnProperty, 2: i32 ColWidth, 3: i32 ColPosition, 4: bool ColAscending, 5: i32 ColSortOrder, } 结构

我正在开发一个用C#编写的客户机-服务器应用程序,它是使用Apache THRIFT RPC框架构建的

我们已经创建了几个带有服务定义的IDL文件(.thrift文件)。这些服务已经在服务器中实现,并且正在从客户端调用

下面给出了IDL文件中结构和服务定义的示例

结构视图列{

1: string ColumnProperty,
2: i32 ColWidth,
3: i32 ColPosition,
4: bool ColAscending,
5: i32 ColSortOrder,
}

结构FormView{

   1: i32 ID
   2: string formname
   3: list<ViewColumn> SelectedColumns
}

在整个应用程序中定义了许多这样的服务

在服务器中,服务的实现如下

    Public FormView FetchFormView() {

  return something

}
客户端和服务器的配置如下所示

    Public FormView FetchFormView() {

  return something

}
客户 1.小盒 2 TBinaryprotocol 3.多路复用协议

服务器 1.服务器插座 2.多路处理器 3.二萘酚

从客户端调用服务时,如下所示

var f=querys.FetchFormView()

我们遇到了一些问题

  • FetchFormView()返回null
  • system.OutOfMemoryException
  • 下面提供了这些错误的堆栈跟踪

    Exception of type 'System.OutOfMemoryException' was thrown.
       at Thrift.Protocol.TBinaryProtocol.ReadStringBody(Int32 size) 
       at Thrift.Protocol.TBinaryProtocol.ReadMessageBegin() 
       at Thrift.Protocol.TProtocolDecorator.ReadMessageBegin() 
       at Queries.recv_FetchFormView()
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    FetchFormView failed: unknown result (result is null)
    NOTE: This error occurs with other defined services also
       at Queries.recv_FetchFormView()
       at Queries.Client.FetchFormView()
       at Queries.FetchFormView()
       at System.Windows.Forms.ToolStripDropDownItem.OnDropDownShow(EventArgs e)
       at System.Windows.Forms.ToolStripMenuItem.OnDropDownShow(EventArgs e)
       at System.Windows.Forms.ToolStripDropDownItem.ShowDropDownInternal()
       at System.Windows.Forms.ToolStripDropDownItem.ShowDropDown(Boolean mousePush)
       at System.Windows.Forms.ToolStripMenuItem.OnMouseButtonStateChange(MouseEventArgs e, Boolean isMouseDown)
       at System.Windows.Forms.ToolStripMenuItem.OnMouseDown(MouseEventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleMouseDown(MouseEventArgs e)
       at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStrip.OnMouseDown(MouseEventArgs mea)
       at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ToolStrip.WndProc(Message& m)
       at System.Windows.Forms.MenuStrip.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    如果您有在企业级应用程序中使用Apache THRIFT的经验,请向我提供见解/解决方案/想法和最佳方法

    这是一个危急的情况。感谢您的帮助

    非常感谢

    罗米

    更新-2013年7月26日


    我临时想出了一个解决办法。在每次服务调用之前,我关闭/处理并重新创建传输和协议对象。这是一种与服务器连接的低效方式,但它正在工作。我正在考虑使每个服务调用异步。这可能是一个更好的解决方案。

    如果在服务器上使用TMMultiplexedProcessor,则必须在客户端上使用TMMultiplexedProtocol

    以下是您报告的堆栈:

    • 客户1。TSocket&TBinaryprotocol
    • 服务器1。t服务器插座2。t多路复用处理器3。 二萘酚
    应该是这样的:

    TTransport trans = new TSocket("localhost", 9090));
    TProtocol proto = new TBinaryProtocol(trans);
    TMultiplexedProtocol mproto = new TMultiplexedProtocol(proto, "FormQueries");
    FormQueries.Client Queries = new FormQueries.Client(mproto);
    var f = Queries.FetchFormView()
    
    • 客户1。t插座2。TBinaryprotocol 3.t多路协议
    • 服务器1。t服务器插座2。t多路复用处理器3。二萘酚
    在客户机上,类似以下内容:

    TTransport trans = new TSocket("localhost", 9090));
    TProtocol proto = new TBinaryProtocol(trans);
    TMultiplexedProtocol mproto = new TMultiplexedProtocol(proto, "FormQueries");
    FormQueries.Client Queries = new FormQueries.Client(mproto);
    var f = Queries.FetchFormView()
    

    这假设FormQueries服务是使用“FormQueries”键添加到服务器上的TMultiplexedProcessor的,该字符串是服务器确定调用哪个服务的方式,因此它必须在客户端和服务器上匹配。

    感谢您的回复。所有服务都已输入TMMultiplexedProtocol。在我写这篇文章的时候,我错误地忽略了这一点。与此同时,我用一个即兴的解决方案更新了这篇文章。但我不确定这是一条正确的道路。