【发布时间】:2013-08-14 20:04:47
【问题描述】:
在客户端,我处理代理状态,以便当它的 State==CommunicationState.Faulted 时,它会自动调用 Abort() 并优雅地转换到 CommunicationState.Closed。 在服务器端,我有 2 个事件连接到回调通道
OperationContext.Current.Channel.Faulted += Channel_Faulted;
OperationContext.Current.Channel.Closed += Channel_Closed;
这是我的活动代码
private void Channel_Closed(object sender, EventArgs e)
{
var callback = sender as IPtiCommunicationCallback;
PtiClient client;
lock (syncObj)
{
client = clientsList.FirstOrDefault(x => x.Value == callback).Key;
}
if (client != null)
{
//Code to remove client from the list
Disconnect(client);
}
}
private void Channel_Faulted(object sender, EventArgs e)
{
(sender as ICommunicationObject).Abort();
}
现在的问题是:双工通道(回调通道)的状态会自动转换为客户端的状态,还是我必须像我一样处理故障状态?顺便说一句,我正在使用 NetTcpBinding。
【问题讨论】:
-
我开发了 wcf 双工服务,但那些事件没有通过 Internet 正确触发。所以我使用计时器每 10 分钟检查一次连接状态。
-
你能详细说明为什么他们没有被正确解雇吗?你用的是什么绑定?现在我只关心通过 Intranet 的 nettcpbinding。但很高兴了解更多