Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将双工通道';NetTcpBinding中的状态会相应地自动转换到客户端';s_C#_Wcf_.net 4.5 - Fatal编程技术网

C# 将双工通道';NetTcpBinding中的状态会相应地自动转换到客户端';s

C# 将双工通道';NetTcpBinding中的状态会相应地自动转换到客户端';s,c#,wcf,.net-4.5,C#,Wcf,.net 4.5,在客户端,我处理代理状态,以便当其状态==CommunicationState.Faulted时,它将自动调用Abort(),并正常转换为CommunicationState.Closed。 在服务器端,我有两个事件连接到回调通道 OperationContext.Current.Channel.Faulted+=Channel\u Faulted OperationContext.Current.Channel.Closed+=Channel\u Closed 这是我的活动代码 private

在客户端,我处理代理状态,以便当其状态==CommunicationState.Faulted时,它将自动调用Abort(),并正常转换为CommunicationState.Closed。 在服务器端,我有两个事件连接到回调通道

OperationContext.Current.Channel.Faulted+=Channel\u Faulted
OperationContext.Current.Channel.Closed+=Channel\u 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。

回调通道的状态通常会模拟客户端的状态,但这不保证。例如,如果客户端试图到达服务器以关闭连接,则其状态可能是
关闭
,而服务器端的状态可能是
打开
。假设每一方都必须分别处理
关闭
故障
状态,这是正确的处理方法。

我对我们应该使用哪种绑定做了一些研究,最后决定继续使用nettcp绑定。有关详细说明,请参见我的博客


我不知道为什么这些事件没有发生。但是每10分钟从客户端触发一次WCF呼叫,我们的问题就解决了。

我已经开发了WCF双工服务,这些事件没有通过互联网正确触发。所以我用定时器每10分钟检查一次连接状态。你能详细解释一下为什么它们没有被正确触发吗?你用了什么装订?现在我只关心内联网上的nettcpbinding。但知道更多是件好事