简体   繁体   English

远程呼叫永不返回

[英]Remoting call never returns

I have a windows service which spawns a child process on the same machine. 我有一个Windows服务,该服务在同一台计算机上生成一个子进程。 They communicate two way via TCP remoting. 他们通过TCP远程通信进行两种方式。 The child process has no problem pinging the parent, but ping calls from the parent's client to the child process's remote service never return. 子进程对父进程执行ping操作没有问题,但是从父级客户端到子进程的远程服务的ping调用永远不会返回。

Logs show the child process registers the server channel with the expected port and service name. 日志显示子进程使用预期的端口和服务名称注册了服务器通道。 However, I provide 127.0.0.1 as host, but when looking at the uri value in ChannelData I see the machine's actual ip address instead of the loopback address. 但是,我提供127.0.0.1作为主机,但是当查看ChannelData中的uri值时,我看到的是机器的实际IP地址而不是环回地址。 Registering the child's server channel with this actual ip address instead of 127.0.0.1 makes no difference. 使用此实际IP地址而不是127.0.0.1注册子级的服务器通道没有区别。

Netstat indicates that the expected port is listening: Netstat指示预期的端口正在侦听:

TCP   0.0.0.0:23167   pc-name:0   LISTENING   hostingProcId
TCP   0.0.0.0:23461   pc-name:0   LISTENING   hostedProcId

The service is WellKnownObjectMode.Singleton. 该服务是WellKnownObjectMode.Singleton。 I don't know if the following info matters, but just in case, I do not override the marshallable object's InitializeLifetimeService. 我不知道以下信息是否重要,但以防万一,我不会覆盖可编组对象的InitializeLifetimeService。

adding secure=false to the cahnnel properties did not do the trick, and neither did explicitly setting in and out firewall rules on the relevant port. 向cahnnel属性添加secure = false并不能解决问题,也没有在相关端口上明确设置防火墙规则。

I synchronize cross-process to ensure the client does not try to activate the remote object before the child process is fully set up. 我同步跨进程以确保客户端在完全设置子进程之前不会尝试激活远程对象。

Any ideas? 有任何想法吗?

Client setup on the parent: 父客户端上的客户端设置:

protected RemotingTcpClient(IpcUniplexConfig config)
{
    Host = config.Host;
    Port = config.Port;
    ServiceName = config.ServiceName;

    var props = new Hashtable();
    props["name"] = ServiceName;
    props["timeout"] = config.Timeout;        

    Channel = new TcpClientChannel(props, null);
    ChannelServices.RegisterChannel(Channel, true);

    var uri = string.Format("tcp://{0}:{1}/{2}", Host, Port, ServiceName);           
    Service = (TService)Activator.GetObject(typeof(TService), uri);
}

Client on the parent: 父母的客户:

public IpcCallResponseData PingHostedProcess(int processId)
{
    return Service.Ping(new IpcCallRequestData(processId));
}

Server setup on the child: 子级上的服务器设置:

protected RemotingTcpServer(IpcUniplexConfig config, TService service, WellKnownObjectMode objectMode)
{
    Port = config.Port;
    Service = service;

    var props = new Hashtable();
    props["port"] = Port;
    props["name"] = service.ServiceName;

    Channel = new TcpServerChannel(props, null);
    ChannelServices.RegisterChannel(Channel, true);
    RemotingConfiguration.RegisterWellKnownServiceType(Service.GetType(), Service.ServiceName, objectMode);
}

Service on the child: 对孩子的服务:

public IpcCallResponseData Ping(IpcCallRequestData data)
{
    ... some processing ...
    return new IpcCallResponseData(_processId);
}

If you want two way communication then both your client and server will need to register both a client and server channel. 如果要双向通信,则客户端和服务器都需要注册客户端和服务器通道。

Hopefully if you create and register a TcpClientChannel in RemotingTcpServer , then create and register a TcpServerChannel in RemotingTcpClient that listens on the same port it may work! 我们希望,如果你创建并注册一个TcpClientChannelRemotingTcpServer ,然后创建并注册一个TcpServerChannelRemotingTcpClient ,它可以工作在同一个端口上侦听!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM