2013-06-20 116 views
0

意外关闭基础连接已关闭:连接被意外关闭基础连接已关闭:连接被WCF服务

这是一般性错误,因为我很新的WCF我不知道从哪里开始诊断问题。我一直在谷歌搜索几个小时,真的需要有更多的经验与wcf的人的建议。所以请耐心等待,我会尽我所能地描述问题。 我的域由一个wcf项目和一个类库项目组成,其中我拥有数据实体。我有1个svc文件。我在我的asp.net mvc 3控制器中调用该服务。做一些很简单的事情。我将发布相关代码和堆栈跟踪。

我想在候选人控制器的列表动作中显示候选人列表。我向mvc项目添加了一个服务引用,并将其指向我的localhost(它被发现并正在运行的服务)。

堆栈跟踪:

[WebException: The underlying connection was closed: The connection was closed unexpectedly.] 
    System.Net.HttpWebRequest.GetResponse() +6117395 
    System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +48 

[CommunicationException: The underlying connection was closed: The connection was closed unexpectedly.] 
    System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9440287 
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345 
    ADMWeb.UI.ADMServices.IADM.GetCandidateList() +0 
    ADMWeb.UI.ADMServices.ADMClient.GetCandidateList() in C:\Users\ori\Documents\Visual Studio 2010\Projects\ADMWeb\ADMWeb.UI\Service References\ADMServices\Reference.cs:1025 
    ADMWeb.UI.Controllers.CandidatesController.Index() in C:\Users\ori\Documents\Visual Studio 2010\Projects\ADMWeb\ADMWeb.UI\Controllers\CandidatesController.cs:22 
    lambda_method(Closure , ControllerBase , Object[]) +62 
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17 
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27 
    System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263 
    System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343 
    System.Web.Mvc.Controller.ExecuteCore() +116 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97 
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37 
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21 
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12 
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50 
    System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7 
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60 
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9030045 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184 

的错误:

Line 1024:  public ADMWeb.UI.ADMServices.Candidate[] GetCandidateList() { 
Line 1025: return base.Channel.GetCandidateList(); Line 1026:  } 

ADM.svc:

namespace ADMServices 
{ 
    public class ADM : IADM 
    { 
     public List<Candidate> GetCandidateList() 
     { 
      List<Candidate> candidateList = new List<Candidate>(); 
      candidateList = CandidateManager.GetCandidateList(); 

      return candidateList; 
     } 
    } 
} 

考生控制器(list动作):

ADMClient client = new ADMClient(); 
List<Candidate> candidates = client.GetCandidateList().ToList(); 
return View(candidates); 

WCF项目的web.config:

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <connectionStrings> 
    <add name="ADMConnectionString" connectionString="Data Source=;Initial Catalog=ADM_ATID;Persist Security Info=True;User ID;Password" 
    providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
    <system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel" 
       switchValue="Information, ActivityTracing" 
       propagateActivity="true" > 
     <listeners> 
      <add name="xml"/> 
     </listeners> 
     </source> 
     <source name="System.ServiceModel.MessageLogging"> 
     <listeners> 
      <add name="xml"/> 
     </listeners> 
     </source> 
     <source name="myUserTraceSource" 
       switchValue="Information, ActivityTracing"> 
     <listeners> 
      <add name="xml"/> 
     </listeners> 
     </source> 
    </sources> 
    <sharedListeners> 
     <add name="xml" 
      type="System.Diagnostics.XmlWriterTraceListener" 
      initializeData="Error.svclog" /> 
    </sharedListeners> 
    </system.diagnostics> 
</configuration> 

MVC的web.config:

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding name="BasicHttpBinding_IADM" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
     useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
     maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="None"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<client> 
    <endpoint address="http://localhost:49341/ADM.svc" binding="basicHttpBinding" 
    bindingConfiguration="BasicHttpBinding_IADM" contract="ADMServices.IADM" 
    name="BasicHttpBinding_IADM" /> 
</client> 

+0

嗨Olst,你找到解决方案吗?在我最后一个问题上,我一直在等待你的回复。 – Anu

回答

2

我会做的第一件事是,而不是返回的候选人,我将返回的完整列表,一个空的列表。如果工作正常,那么很明显数据的大小是一个问题。使用绑定参数修改大小播放。

+0

谢谢,你是对的,一个空的清单工作得很好。你能否详细说明你的意思是“与你的绑定参数一起玩”? – vobs

+0

可以请你发布你的配置文件绑定和行为 – Anu

+0

嗨,抱歉的延迟,但虽然空列表返回OK,我试着做一个10条记录查询,它仍然给出了错误。会发布我的配置。 – vobs

相关问题