【问题标题】:Hosting remoting singleton in IIS, clients can block the server在 IIS 中托管远程单例,客户端可以阻止服务器
【发布时间】:2010-10-28 19:49:00
【问题描述】:

我们有一个托管在 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>

【问题讨论】:

    标签: .net singleton remoting


    【解决方案1】:

    通过将超时值添加到通道来修复 IIS 的总阻塞

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

    我仍然很惊讶一个阻塞的客户端会导致与其他机器的连接开始失败。

    【讨论】:

      猜你喜欢
      • 2015-01-04
      • 1970-01-01
      • 1970-01-01
      • 2011-10-09
      • 1970-01-01
      • 2018-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多