简体   繁体   English

通过net.tcp的双工WCF服务失败

[英]Duplex WCF service over net.tcp failing

I have a duplex WCF service that I am connecting to over net.tcp. 我有一个通过W.net连接到的双工WCF服务。 When the service first starts up I am able to call it and receive callbacks just fine and but after a few minutes I start getting this error from the service: 当服务首次启动时,我可以调用它并接收回调,但是几分钟后,我开始从服务中收到此错误:

A TCP error (995: The I/O operation has been aborted because of either a thread exit or an application request) occurred while transmitting data. 传输数据时发生TCP错误(995:由于线程退出或应用程序请求,I / O操作已中止)。

I've tried hosting the service in IIS as well as a windows service but I get the same error in both. 我曾尝试在IIS和Windows服务中托管该服务,但在两者中都遇到相同的错误。 In my trace log I see that there is a SocketConnection aborted warning just before the exception. 在我的跟踪日志中,我看到在异常发生之前有一个SocketConnection中止警告。

What is causing this? 是什么原因造成的?

The method I am using for keeping track of subscribers of the service I got from here . 我用于跟踪从此处获得的服务的订户的方法。 I can post my config if needed but didn't want to clutter up my question if it's not. 如果需要,我可以发布我的配置,但如果不是,我不想弄乱我的问题。

There are 2 aspects: 有两个方面:

  1. Why exception occurred 为什么发生异常

may be this post can help (in short - in his situation Antivirus was responsible for error) 可能是帖子可以提供帮助(总之-在他的情况下,防病毒是造成错误的原因)

  1. What happens with connection and client's callback - exception, not wrapped by Fault will "kill" the connection, and your client will not be able to re-use it, it'll receive "aborted" error. 连接和客户端的回调会发生什么情况-异常(不是由Fault包裹)会“杀死”连接,并且您的客户端将无法重新使用它,它将收到“异常终止”错误。

You need to subscribe on the client side for failed calls, and re-init your connection. 您需要在客户端订阅失败的呼叫,然后重新初始化连接。

Like 喜欢

((IClientChannel)YourClient).Faulted += InnerChannel_Faulted;
}


void InnerChannel_Faulted(object sender, EventArgs e)
{

    TWLogger.Write("Faulted event ... ");
    reconnect();
} 

Also, I'd recommend to wrap all server-side exceptions with Fault 另外,我建议将所有服务器端异常包装为Fault

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM