C# 当我抛出FaultException时WCF通道重试5次
我正在使用C# 当我抛出FaultException时WCF通道重试5次,c#,wcf,channelfactory,faultexception,C#,Wcf,Channelfactory,Faultexception,我正在使用DuplexChannelFactory而不是生成的代理创建WCF客户端频道 对于一个特定的方法,我在服务器端抛出一个已知的FaultException。我已根据需要使用[FaultContract(typeof(MyFault))]标记了服务接口 在客户端,我捕获这个FaultException并显示一个错误 所有这些工作都非常好,但出于某种原因,WCF在将控制权返回到我的客户机代码之前,正在重试服务调用5次。这会在客户端上造成明显的延迟 调试器在我的客户机代码中的服务调用上中断5次
DuplexChannelFactory
而不是生成的代理创建WCF客户端频道
对于一个特定的方法,我在服务器端抛出一个已知的FaultException
。我已根据需要使用[FaultContract(typeof(MyFault))]
标记了服务接口
在客户端,我捕获这个FaultException
并显示一个错误
所有这些工作都非常好,但出于某种原因,WCF在将控制权返回到我的客户机代码之前,正在重试服务调用5次。这会在客户端上造成明显的延迟
调试器在我的客户机代码中的服务调用上中断5次,然后继续下一行代码。我无法进入它,但调用堆栈显示在WCF的深处抛出异常
服务端上的断点只触发一次
一旦控制返回给我,通道就不会出现故障
调试器输出显示:
A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in MyService.dll
Additional information: Fault Test
A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll
Additional information: Fault Test
A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll
Additional information: Fault Test
A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll
Additional information: Fault Test
A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll
Additional information: Fault Test
A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in mscorlib.dll
Additional information: Fault Test
这是正常的行为吗?当我返回已知的预期故障时,为什么WCF会重试?您使用的是可靠的会话吗?我这样问是因为我正在考虑使用自定义绑定时可用的reliableSession中的MaxRetryCount属性。谢谢您的建议。我使用命名管道,所以我隐式地获得可靠的会话。查看了MaxRetryCount的文档后,默认值似乎是8,而不是5,我不会在任何地方设置它。超时时间加倍似乎很有趣,因为我想知道,即使有5个调用,它的速度也慢到足以引起注意。第一个异常可能是FaultException。您确定所有附加的异常都是该类型的,而不是其他类型的吗?这是不正常的,但如果你想让我们做更多的事情,你可能需要发布一些代码和配置。