说到wcf,本人也是刚刚使用所以不是很熟悉

在做项目的时候采用webservice+客户端程序架构

写了一个wcf中的webservice之后,又写了很多的客户端exe程序,有的是轮询调用这个webservice方法,有的是仅仅调用一次webservice方法的exe程序,

在单元测试的时候都是没有遇到问题,结果却在做整合测试的时候发现发现了如下的错误,倒是所有程序都不能正常运行:

System.TimeoutException: The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: The HTTP request to 'http://192.168.3.112:8080/Service.svc' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout. ---> System.Net.WebException: The operation has timed out
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
   at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at PortalClient.SvcRef.IService.GetExcelToTxt()
   at PortalClient.SvcRef.ServiceClient.GetExcelToTxt() in D:\MAXNET_PROJECT\03_SourceCode\MAXNET\05_MaximOOS\MaximOOS\Maxim.PortalClient\Service References\SvcRef\Reference.cs:line 2653
   at Maxim.PortalClient.SrvBox.btnTestWriteTxt_Click(Object sender, EventArgs e) in D:\MAXNET_PROJECT\03_SourceCode\MAXNET\05_MaximOOS\MaximOOS\Maxim.PortalClient\SrvBox.cs:line 26

看了上面的错误,估计大家都应该知道是什么错误了吧,对,是调用超时。

当时看到这个错误,我的第一反应就是可能传输的问题,但是代码没有问题,因此我就修改了客户端调用webservice的响应时间改成5分钟,结果令人不满意,还是不行

后来我就试了一下重启iis结果,我发现在第一次调用webservice的时候成功了,但是在随后的调用中又出现了上面的错误,但是真的差点崩溃了,

一直到加班结束,我在回家的路上突然想到了我以前遇到超时的问题是数据库连接超时,是因为连接打开然后没有关闭,导致数据打开的连接数超过上限以致超时的,

回到家后我立即采用简单的测试,终于发现了在wcf中的webservice也是要关闭的(其实在示例代码中有说要close()的,可是我没注意),如果不关闭的话,我测试了一下,档调用webservice超过10次的时候,webservcie就死掉了,以致以后再调都不可以了(这个会不会是微软的bug呀,因为如果这种问题出现的话,要想让webservice死掉的话,我只有调用webservice然后不做关闭处理就可以实现了),这个和以前的webservice(asmx)方案是完全不一样的,webservice(asmx)不需要关闭

还有我发现调用wcf写的服务没有调用webservice(asmx)的速度开,性能可能wcf没有webservice(asmx)好,但是可靠性应该还可以的

这个是小弟的第一篇blog,谢谢支持!

wcf 中客户端调用之死 感悟 wcf与原来的webservice2.0 的客户端调用区别(wcf调用完不关闭的话那就把web服务搞死了)的更多相关文章

  1. windows环境下解决web服务假死的问题

    最近在windows系统在部署web服务器,发现很不稳定.web服务有容易假死,改过配置换过各种web软件,如apache.nginx都不管用. 所以干脆做个简易的定时检测Web服务状态的软件.一旦w ...

  2. WCF中的标准绑定

    使用过WCF的童鞋们都很清楚,绑定是必须的.我将这些绑定总结了下. 一.标准绑定简要说明 1.basicHttpBinding 基于WS-I Basic Profile 1.1 的web服务,所需的. ...

  3. 跟我一起学WCF(10)——WCF中事务处理

    一.引言 好久没更新,总感觉自己欠了什么一样的,所以今天迫不及待地来更新了,因为后面还有好几个系列准备些,还有很多东西需要学习总结的.今天就来介绍下WCF对事务的支持. 二.WCF事务详解 2.1 事 ...

  4. WCF中事务处理

    一.引言 今天来介绍下WCF对事务的支持. 二.WCF事务详解 2.1 事务概念与属性 首先,大家在学习数据库的时候就已经接触到事务这个概念了.所谓事务,它是一个操作序列,这些操作要么都执行,要么都不 ...

  5. mvc路由引起异步调用web服务的问题

    从一篇blog得知使用脚本可以异步调用Web服务,觉得很新鲜,因为自己很少用到Web服务,所以决定写一写看看什么效果. 首先在UI项目(我使用的是MVC4.0)里创建一个Web服务. 添加Web服务后 ...

  6. 动态的调用服务端的WCF中的方法

    客户端调用wcf ,有时需要动态的调用服务端的WCF中的方法,本方法,反射wcf 的接口,动态调用接口中的方法. 主要为,动态绑定,反射动态调用. public static object Execu ...

  7. ajax调用本地wcf中的post和get

    我们可以通过jQuery调用本地或者远程的wcf服务,本文讲解的是对本地wcf服务的post和get调用方式. post和get到底有什么区别呢?此处不作详述. 但是,post对请求的数据格式更为严格 ...

  8. WCF中修改接口或步骤名称而不影响客户端程序

    WCF中修改接口或方法名称而不影响客户端程序 本篇接着"从Web Service和Remoting Service引出WCF服务"中有关WCF的部分. 运行宿主应用程序. 运行We ...

  9. WCF学习之旅—WCF中传统的异常处理(十六)

    WCF中的异常处理 在软件开发过程中,不可能没有异常的出现,所以在开发过程中,对不可预知的异常进行解决时,异常处理显得尤为重要.对于一般的.NET系统来说,我们简单地借助try/catch可以很容易地 ...

随机推荐

  1. Managed C++ dll: #define _AFXDLL or do not use /MD[ d]?

    [问题] Hello all     I'm writing a managed C++ dll with will be acting as an intermediate between a lo ...

  2. junit与spring-data-redis 版本对应成功的

    spring-data-redis  版本:1.7.2.RELEASE junit 版本:4.12

  3. Java集合遍历时删除

    public static void main(String[] args){ List<Integer> list = new ArrayList<Integer>(); l ...

  4. ivr

    /************************************************************* 北京高阳圣思园信息技术有限公司IVR业务: 流程说明:公司介绍子流程 发布 ...

  5. android studio开发的时候出现design editor is unavailable until after a successful project sync问题的解决方法

    android studio设计界面的时候,出现了报错:design editor is unavailable until after a successful project sync,导致无法编 ...

  6. 使用树莓派3获取CPU温度

    一.命令: cat /sys/class/thermal/thermal_zone0/temp 二.上图:

  7. 006-GO VSCode 自动提示功能提示PANIC

    通过vscode开发go,之前一直正常,后来不知什么原因自动提示一直提示:PANIC, 解决方法: (1)重新下载gocode go get -u github.com/nsf/gocode (2)重 ...

  8. C#判断网站是否能访问或者宕机的方法

    最近有位朋友说他有很多网址,可能有些已经过期或者不能访问了.自己去一个一个点可以,但又很麻烦! 再过一段时间又要去检查一次,每次都这样就不方便了! 于是就做了个小程序给帮他检测一下. 以下做了一个例子 ...

  9. CTP交易函数大全

    管理接口 交易接口

  10. 转:VS2013快捷键大全

    Ctrl+E,D ----格式化全部代码 Ctrl+E,F ----格式化选中的代码 CTRL + SHIFT + B生成解决方案 CTRL + F7 生成编译 CTRL + O 打开文件 CTRL ...