【发布时间】: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>
【问题讨论】: