简体   繁体   English

在.Net Remoting中,“。NET Remoting框架”到底是什么?

[英]In .Net Remoting, what or where specifically is the “.NET Remoting Framework”?

tl;dr: tl; dr:

I'm trying to find where the .Net Remoting Framework runs (eg, a service name or process name). 我试图找到.Net Remoting Framework的运行位置(例如,服务名称或进程名称)。 Additionally, source would be amazing. 此外,来源将是惊人的。

Context: 内容:

I'm maintaining legacy code that uses .Net remoting to allow the use of objects that store connection information between two processes, and which has long had problems with random disconnects and crashes apparently due to those remoting objects timing out. 我正在维护使用.Net远程处理的旧代码,以允许使用存储两个进程之间的连接信息的对象,并且长期以来一直存在随机断开连接的问题,并且显然由于那些远程处理对象超时而导致崩溃。 The issue we've seen is spoken about in the answer for this post , specifically the bit: 这篇文章的答案中提到了我们所看到的问题,特别是一点点:

My issue was using the Marshal to register the remoting object. 我的问题是使用元帅注册远程对象。 Over time the remoting object will disappear for clients to consume, ie no longer on the remoting object. 随着时间的流逝,远程对象将消失以供客户端使用,即不再在远程对象上使用。

The approach to 'fixing' this we used in the past was what was mentioned in that post : returning a null lease manager, which keeps objects alive forever, in order to avoid the random unwanted timeout. 我们在过去使用的“修复”方法就是该文章中提到的:返回一个空的租约管理器,该管理器可以使对象永远存活,以避免随机的不必要的超时。

A few years ago, that code was removed due to it causing an issue on Linux - basically, each connection left alive after it was useful would consume a socket, and since sockets are files on Linux, we'd run out of file descriptors. 几年前,该代码被删除是因为它在Linux上引起了问题-基本上,每个连接在有用后仍处于活动状态会消耗一个套接字,并且由于套接字是Linux上的文件,因此我们用完了文件描述符。 As we thought the functionality that the timeout issue most affected had been deprecated, we reinstated regular timeouts, and everything was fine for two years. 由于我们认为不建议使用最受影响的超时问题的功能,因此我们恢复了定期超时,并且一切正常,已经有两年了。

Recently, however, a recent patch to Windows or some other environmental change seems to have caused the unwanted timeout issue to come back in full force on some of our machines (on Windows only; Mono seems to handle this workflow fine, giving me the strong hunch that it's a .Net bug). 但是,最近,最近对Windows的补丁程序或其他一些环境变化似乎已经导致不必要的超时问题在我们的某些计算机上重新发挥了作用(仅在Windows上; Mono似乎可以很好地处理此工作流程,这给了我强大的支持。预感这是一个.NET错误)。 Specifically, any time we attempt to connect a new client after another client has maintained a connection for ~5 hours or more, the process hangs on trying to connect to a TCP port that, if I understand correctly, is what the Remoting Framework told us is where our server is listening. 具体来说,每当我们尝试在另一个客户端保持连接约5小时或更长时间之后尝试连接新客户端时,该过程就会挂起,尝试连接到TCP端口,如果我理解正确的话,这就是Remoting Framework告诉我们的内容是我们的服务器正在监听的位置。

As this cripples our Windows usage, it's resulted in this defect finally getting a push to be correctly solved, and what I'm trying to figure out now is why, after a period of time ~5 hours of constant connection from one client, we're no longer able to make remoting connections from a new client process to the server. 由于这严重损害了我们的Windows使用率,导致该缺陷最终得到了正确解决的推动力,而我现在想找出的是为什么在经过一个客户端约5小时的持续连接后,我们不再能够从新的客户端进程到服务器建立远程连接。 But first, in order to do that, I want to understand the whole workflow, which includes knowing what's going on in the .Net Remoting Framework that stores the needed information for the remoting connection to be created in the first place. 但是首先,为了做到这一点,我想了解整个工作流程,包括了解.Net Remoting Framework中正在发生的事情,该框架存储了首先要创建的远程连接所需的信息。 However, everything I've read just mentions the Framework in passing, not explaining what exactly it is. 但是,我所读的所有内容只是在顺便提及了框架,而没有解释其确切含义。

Question: 题:

Many different (PDF warning) articles on .Net remoting refer to the ".Net Remoting Framework" as being the critical piece that stores information about objects registered with either RemotingServices.Marshal or RemotingServices.RegisterWellKnownSericeType . 关于.Net远程处理的许多 不同 (PDF警告) 文章都将“ .Net Remoting框架”称为存储有关通过RemotingServices.MarshalRemotingServices.RegisterWellKnownSericeType注册的对象的信息的关键部分。 If I understand correctly, it then allows other client .Net processes to query it for those objects using a URI that both processes know as a key. 如果我理解正确,那么它将允许其他客户端.Net进程使用两个进程都称为键的URI向其查询那些对象。

Where is this process or service that gets queried? 在哪里查询此过程或服务? Honestly, even if the answer is something I've somehow missed clearly mentioned in the documentation, I would be ecstatic just for having it. 老实说,即使答案是我在文档中明确提到的某种漏掉的东西,我也会为得到它而欣喜若狂。 Thanks! 谢谢!

(Also, of course, any additional insight on my greater problem would be appreciated.) (当然,对我的更大问题的任何其他见解也将不胜感激。)

Edit : The 'greater problem' appears to be that a security software program we were running was interfering with the network adapters in our work machines, sometimes causing System.Net.Sockets.SocketExceptions to occur during our remoting program's attempt to connect through those sockets. 编辑 :“更大的问题”似乎是我们正在运行的安全软件程序正在干扰我们工作计算机中的网络适配器,有时会导致在我们的远程处理程序尝试通过那些套接字进行连接期间发生System.Net.Sockets.SocketExceptions 。 This meant that when the LeaseManager went to check if a Lease was still working for a RemotingObject, it'd see a socket error and reflexively consider the Lease as disconnected, and as such drop the object reference we wanted kept alive. 这意味着,当LeaseManager检查Lease是否仍在为RemotingObject工作时,它会看到套接字错误,并反身认为Lease已断开连接,因此删除了我们想要保留的对象引用。 Our approach will be to return the InitializeLifetimeService function to be returning null, and handle all object garbage collection ourselves using the Dispose pattern. 我们的方法是将InitializeLifetimeService函数返回为null,并使用Dispose模式自己处理所有对象垃圾回收。 Full description is here. 完整描述在这里。

It runs wherever the application which defines a host in the 它可以在定义了主机的应用程序的任何位置运行 configuration section, which can be IIS, a Windows service, or console application. 配置部分,可以是IIS,Windows服务或控制台应用程序。 The client application will need to have some configuration as well, to tell it that the class is really a proxy to a remoting host. 客户端应用程序也将需要进行一些配置,以告知该类确实是远程主机的代理。

The types which are used in remoting are in the Sytem.Runtime.Remoting namespace. 远程处理中使用的类型在Sytem.Runtime.Remoting命名空间中。

I've never used remoting where I kept the object proxy alive for hours; 我从来没有使用过将对象代理保持活动数小时的远程处理。 I'd think you'd normally want to new one up, use it, then discard it. 我想您通常会想要重新使用它,然后丢弃它。 If that's not possible, check the mode. 如果那不可能,请检查模式。 SingleCall is probably the best option, as on the host side a new object is created for each remoting request, and destroyed when done. SingleCall可能是最好的选择,因为在主机端会为每个远程请求创建一个新对象,并在完成后销毁该对象。 Longer lived objects may have some stale state that hangs around if not coded correctly, or perhaps there's a memory leak or some other issue. 如果编码不正确,则寿命较长的对象可能会处于一些过时的状态,或者存在内存泄漏或其他问题。

We still use remoting as well for a ClickOnce smart client, and we don't have the timeout issues you're encountering, but our remoting is configured for SingleCall only. 对于ClickOnce智能客户端,我们仍然也使用远程处理,并且没有遇到超时问题,但是我们的远程处理仅配置为SingleCall。

From the link, this would be the configuration in the hosting application: 通过链接,这将是托管应用程序中的配置:

<configuration>
  <system.runtime.remoting>
    <application>
      <service>
        <wellknown mode="SingleCall" type="Hello.HelloService, Hello" 
objectUri="HelloService.soap" />
      </service>
    </application>
  </system.runtime.remoting>
</configuration>

And this on the client: 而在客户端上:

<configuration>
  <system.runtime.remoting>
    <application>
      <client>
        <wellknown type="Hello.HelloService, Hello" 
url="http://localhost:8000/HelloService.soap" />
      </client>
    </application>
  </system.runtime.remoting>
</configuration>

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

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