나는 정기적 인 net.tcp WCF 서비스 클라이언트와 정기적 인 net.tcp duplex (콜백 포함) WCF 서비스 클라이언트를 가지고 있습니다. 서비스가 실패한 경우에 대비하여 연결을 끊임없이 다시 인스턴스화하는 로직을 구현했습니다.듀플렉스 채널 두 번째 연결 시도시 오류 이벤트가 발생하지 않습니다.
는 그들은 정확히 같은 방식으로 만들어집니다
FooServiceClient Create()
{
var client = new FooServiceClient(ChannelBinding);
client.Faulted += this.FaultedHandler;
client.Ping(); // An empty service function to make sure connection is OK
return client;
}
BarServiceClient Create()
{
var duplexClient = new BarServiceClient(new InstanceContext(this.barServiceCallback));
duplexClient.Faulted += this.FaultedHandler;
duplexClient.Ping(); // An empty service function to make sure connection is OK
return duplexClient;
}
public class Watcher
{
public Watcher()
{
this.CommunicationObject = this.Create();
}
ICommunicationObject CommunicationObject { get; private set; }
void FaultedHandler(object sender, EventArgs ea)
{
this.CommunicationObject.Abort();
this.CommunicationObject.Faulted -= this.FaultedHandler;
this.CommunicationObject = this.Create();
}
}
는 FaultedHandler()
채널을 중단하고 은 위의 코드를 사용하여를 다시 만듭니다.
FooServiceClient
재 연결 논리는 정상적으로 작동하며 많은 오류가 발생한 후에 다시 연결됩니다. 반면, 거의 동일하지만 양방향 인 BarServiceClient
은 BarServiceClient
인스턴스의 오류 이벤트 (예 : ) 만받습니다.
듀플렉스 BarServiceClient
의 첫 번째 인스턴스 만 오류가 발생하는 이유는 무엇입니까? 해결 방법이 있습니까?
유사한 비 대답 질문 : WCF와의 전쟁에 WCF Reliable session without transport security will not faulted event on time
'this.FaultedHandler' 메소드를 게시 할 수 있습니까? –
FaultedHandler 코드로 질문을 업데이트했습니다. –
이제'this.CommunicationObject' 속성을 게시 할 수 있습니까? 전체 수업을 게시 할 수 있다면 더 쉽습니다. –