【发布时间】:2025-11-30 21:10:02
【问题描述】:
我有一个在 Linux 上运行的服务器应用程序。这个应用程序是 使用 protobuf c 和 protobuf.rpc.c 文件进行 RPC 通信开发。
我有一个在 windows 上运行的客户端应用程序。它是用 c# 开发的,使用 protobuf-net.dll 和 ProtobufRemote.dll 进行 RPC 通信。两个应用程序使用相同的 proto 文件,具有相同的服务方法。
我可以使用以下代码从 C# 客户端应用程序创建代理。
using System.Configuration;
using System.Net.Sockets;
using ProtoBufRemote; // rpc reference
using StarCall; // proto file
#region Create client connection
Int32 port = Convert.ToInt32(ConfigurationManager.AppSettings["PORT"]);
TcpClient tcpClient = new TcpClient(ConfigurationManager.AppSettings["SERVERIP"].ToString(), port);
var controller = new RpcController();
var client = new RpcClient(controller);
var channel = new NetworkStreamRpcChannel(controller, tcpClient.GetStream());
channel.Start();
var service = client.GetProxy<Istarcall_services>();
if (service == null)
Console.WriteLine("error creating client..");
//now calls can be made, they will block until a result is received
Console.WriteLine("Client connected to Server....\n");
#endregion
但是每当我尝试从 C# 客户端应用程序调用服务方法时,如下所示,应用程序挂起并且没有从 Linux c 服务器应用程序获得任何响应。
try
{
Room_Config room = new Room_Config();
room.Room_Dial_Num = 1;
Room_Config roomRet = service.read_room(room); // service method
}
catch (Exception)
{
throw;
}
应用程序挂在下面的代码中。
protected RpcMessage.Parameter EndAsyncCallHelper(string methodName, IAsyncResult asyncResult)
{
PendingCall pendingCall = (PendingCall)asyncResult;
pendingCall.AsyncWaitHandle.WaitOne(); // application hanging here
pendingCall.AsyncWaitHandle.Close();
if (pendingCall.IsFailed)
throw new InvalidRpcCallException(serviceName, methodName,
String.Format("Server failed to process call, returned error message: \"{0}\".",
pendingCall.ServerErrorMessage));
return pendingCall.Result;
}
根据上述场景,我有以下疑问。
这个 protobuf 远程 c# dll 是否可以帮助从 linux c 代码创建通信。如果没有,请帮助我如何使用 linux c 代码创建通信通道。
如果有任何替代 rpc dll 供 c# 客户端应用程序与 linux protobuf c 和 protobuf rpc.c 文件通信,请提供。
如果我的上述方法有问题,请告诉我,并使用合适的解决方案进行纠正。
请帮帮我。如果不清楚,请发送到下面提到的邮件。
【问题讨论】:
-
这听起来主要就像 RPC 堆栈正在停止; IMO 首先要检查的是 ProtobufRemote.dll 是否是为这种情况设计的(即它是否与您的 protobuf.rpc.c 服务兼容)。
标签: windows linux communication protocol-buffers