WCF service host 崩溃退出的异常

最近在公司项目中,遇到莫名其妙的异常,就是当使用Windows Service作为WCF服务端宿主程序,并且使用netTcpBinding的时候,Windows服务会时不时的Crash掉。通过分析处理UnHandledException记录下的日志,异常信息大致如下:

[10/26/11 10:10:16.011],[35],ERROR,”Encountered an unhandled thread exception: System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was ‘10675199.02:48:05.4775807’. —> System.IO.IOException: The read operation failed, see inner exception. —> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was ‘10675199.02:48:05.4775807’. —> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

这个issue比较怪异,网上google了一大圈,遇到此类问题的童鞋还真不少。不过解决方法,提到的是放弃使用netTcpBinding,采用HttpBinding或者其他方式的binding即可解决。也没说具体是啥原因,不过,最后终于在Microsoft的网站上找到了答案,原来Microsoft承认这是.NET Framework的bug。并且提供了一个hot fix供下载,hot fix是针对.NET 3.5的,而这个bug貌似在.NET Framework 4.0中也会遇到。因为我们公司的项目就是.NET 4.0的⋯⋯

有人在微软的网站反馈了此问题,帖子在这里:http://connect.microsoft.com/wcf/feedback/details/622164/wcf-servicehost-crashes-when-usernamepasswordvalidator-takes-too-long-to-process

微软提供的hot fix地址:http://support.microsoft.com/kb/2600907

不过针对.NET 4.0的hot fix,不知道是微软没出,还是仍旧在解决中⋯⋯ 反正帖子里面的答复,是说会在下一个版本的.NET Framework中解决,难道是.NET 5.0中么? 汗⋯⋯

支持原创技术分享,据说打赏我的人,都找到了女朋友!