WCF服务给出错误:基础连接已关闭 [英] WCF Service Gives Error: Underlying connection closed

查看:82
本文介绍了WCF服务给出错误:基础连接已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个名为service1的WCF服务,该服务使用了另一个wcf 服务Service2.

I have created WCF service called service1 which consumes another wcf service Service2.

当调用service1的特定方法而内部调用service2的方法时,出现以下错误:

When a particular method is called of service1 which internally calls a method of service2 I am getting below mentioned error:

[WebException:基础连接已关闭:接收时发生意外错误.]

  System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest请求)

   System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)

  System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest请求)

   System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)

  System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(字符串methodName,Object []参数)

   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

相同的方法会在一段时间后起作用.

The same method works after some time.

我观察到100个呼叫中有10个失败,并显示此错误.

I have observed that out of 100 calls 10 fails with this error.

 

请帮助.

 

谢谢

Nis

推荐答案

这是您在生产环境中遇到的错误,还是在VS下运行时?有时我在VS中遇到此错误,必须重新启动.

Is this an error you're getting in the production environment or when running under VS?  Sometimes I get this error in VS and have to restart.

但是我确实找到了一篇文章解决了这个问题,并且由于错误可能是由于连接关闭而导致的,可以解决该问题:

But I did find an article that addresses this issue and might fix it due to the fact the error could be due to a connection closing:

http://geekswithblogs.net/Denis/archive/2005/08/16/50365.aspx

听起来很容易实现,只需覆盖WebRequest即可,当您重新获得WebRequest对象时,将其上的KeepAlive属性设置为true.

It sounds easy to implement, just override WebRequest and when you get the WebRequest object back set the KeepAlive property on it to true.

让我们知道是否可以解决问题.

Let us know if that fixes the problem. 


这篇关于WCF服务给出错误:基础连接已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆