在 IIS 中托管远程单例,客户端可以阻止服务器

发布于 2024-07-22 04:25:12 字数 2680 浏览 3 评论 0原文

我们有一个托管在 IIS 中的远程单例对象,它为多个客户端提供服务。 在开发过程中,我们注意到,如果一个客户端在调试器中停止,所有其他连接的客户端将停止从服务器接收消息。 消息通过事件回调传递,服务器将创建自己的线程来发送消息。 我可以通过将 Sleep 放入客户端事件处理程序来创建相同的行为。 我们在服务器上的跟踪显示对所有客户端事件处理程序的调用都处于阻塞状态。

当同一对象托管在独立的 exe 中时,在调试或以其他方式暂停一个客户端时不会发生阻塞。

我的问题是,为什么我们在 IIS 下托管的对象和独立的 exe 之间看到不同的行为? IIS 中是否有一项设置可以阻止一个客户端阻止其他客户端与单例通信。

该项目最初是一个 2.0 项目,目前它是针对 3.5 框架构建的,尽管我们没有使用任何 3.5 运行时。

客户端的远程处理配置如下

  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="http" port="0" clientConnectionLimit="120" useDefaultCredentials="true" timeout="2000">
          <clientProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </clientProviders>
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </serverProviders>
        </channel>
      </channels>
    </application>
  </system.runtime.remoting>

在 IIS 上,服务器配置如下

<configuration>
<system.runtime.remoting>
    <application>
      <channels>
        <channel ref="http">
          <clientProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </clientProviders>
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
            </serverProviders>
        </channel>
      </channels>
      <service>
        <wellknown mode="Singleton" displayName="NotificationManager"  type="Notification.NotificationManager, Notification"  objectUri="NotificationManager.rem"/>
       </service>
    </application>
</system.runtime.remoting>
</configuration>

独立服务器配置如下:

  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="http" port="8080" clientConnectionLimit="120" useDefaultCredentials="true" timeout="20000">
          <clientProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </clientProviders>
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </serverProviders>
        </channel>
      </channels>
      <service>
        <wellknown mode="Singleton" displayName="NotificationManager" type="Notification.NotificationManager, Notification"  objectUri="NotificationManager.rem"/>
      </service>
    </application>
  </system.runtime.remoting>

We have a remoted singleton object hosted in IIS which is servicing multiple clients. During development we noticed that if one client is stopped in the debugger all other connected clients will stop receiving messages from the server. Messages are delivered via event call backs, the server will create it's own threads to send messages out. I can create the same behavior by putting a Sleep into the client event handler. The tracing we have on the server shows the calls to all the client event handlers are blocking.

When the same object is hosted in a standalone exe no blocking happens when one client is being debugged or otherwise paused.

My question is why are we seeing different behavior between our object being hosted under IIS and a standalone exe? Is there a setting in IIS that would stop one client from blocking the other clients talking to the singleton.

The project was originally a 2.0 project, currently it is being built against the 3.5 framework though we are not using any of the 3.5 runtime.

Remoting for the client are configured like this

  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="http" port="0" clientConnectionLimit="120" useDefaultCredentials="true" timeout="2000">
          <clientProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </clientProviders>
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </serverProviders>
        </channel>
      </channels>
    </application>
  </system.runtime.remoting>

On IIS the server is configured like this

<configuration>
<system.runtime.remoting>
    <application>
      <channels>
        <channel ref="http">
          <clientProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </clientProviders>
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
            </serverProviders>
        </channel>
      </channels>
      <service>
        <wellknown mode="Singleton" displayName="NotificationManager"  type="Notification.NotificationManager, Notification"  objectUri="NotificationManager.rem"/>
       </service>
    </application>
</system.runtime.remoting>
</configuration>

The standalone server is configured like this:

  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="http" port="8080" clientConnectionLimit="120" useDefaultCredentials="true" timeout="20000">
          <clientProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </clientProviders>
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full"/>
          </serverProviders>
        </channel>
      </channels>
      <service>
        <wellknown mode="Singleton" displayName="NotificationManager" type="Notification.NotificationManager, Notification"  objectUri="NotificationManager.rem"/>
      </service>
    </application>
  </system.runtime.remoting>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扬花落满肩 2024-07-29 04:25:12

通过向通道添加超时值修复了 IIS 的完全阻塞

  <channel ref="http" timeout="20000">

我仍然感到惊讶的是,一个阻塞客户端可能会导致与其他计算机的连接开始失败。

Fixed the total blocking of IIS by adding the timeout value to the channel

  <channel ref="http" timeout="20000">

I am still surprised that one blocking client can cause connections to the other machines to start failing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文