2017-05-29 37 views
0

我试图通过WCF服务获取对象列表。一些简单的方法很好。但是,当我尝试获取对象列表调用Wcf函数时,套接字连接中止

我收到以下错误。

错误:套接字连接被中止。这可能是由处理您的消息时出错或远程主机超出接收超时或基础网络资源问题引起的。本地套接字超时为'00:59:59.9949990'。 错误:一个现有的连接被强行远程主机

这里关闭是客户端配置

<system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding name="NetTcpBinding_ISurveyService" sendTimeout="00:05:00" 
      maxBufferPoolSize="20000000" maxBufferSize="20000000" maxReceivedMessageSize="20000000"> 
      <readerQuotas maxDepth="32" maxStringContentLength="200000000" 
      maxArrayLength="200000000" /> 
     </binding> 
     <binding name="NetTcpBinding_ISurveyService1" /> 
     </netTcpBinding> 
    </bindings> 
    <client> 
     <endpoint address="net.tcp://localhost:8523/SurveyService" binding="netTcpBinding" 
     bindingConfiguration="NetTcpBinding_ISurveyService" contract="SurveyApp.SurveyService.ISurveyService" 
     name="NetTcpBinding_ISurveyService"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
     <endpoint address="net.tcp://localhost:8523/SurveyService" binding="netTcpBinding" 
     bindingConfiguration="NetTcpBinding_ISurveyService1" contract="ServiceReference.ISurveyService" 
     name="NetTcpBinding_ISurveyService1"> 
     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 

这是服务库配置:

<system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding name="NetTcpBinding_ISurveyService" openTimeout="00:10:00" 
        closeTimeout="00:10:00" 
        sendTimeout="00:10:00" 
        receiveTimeout="00:10:00" 
       maxReceivedMessageSize="20000000" 
        maxBufferSize="20000000" 
        maxBufferPoolSize="20000000"> 
      <readerQuotas maxDepth="32" 
        maxArrayLength="200000000" 
        maxStringContentLength="200000000" /> 
     </binding> 

     </netTcpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="WcfServiceLibrary1.Service1Behavior" 
     name="SurveyApp.SurveyService.SurveyService"> 
     <endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ISurveyService" 
      contract="SurveyApp.SurveyService.ISurveyService" > 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" 
      contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://localhost:8523/SurveyService" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="WcfServiceLibrary1.Service1Behavior"> 
      <serviceMetadata httpGetEnabled="false" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

这是我的服务合同:

[ServiceContract] 
    public interface ISurveyService 
    { 
     [OperationContract] 
     string GetData(int value); 

     [OperationContract] 
     IEnumerable<Question> GetAllQuestions(); 

     [OperationContract] 
     Test GetElement(); 
    } 

而这是数据连续ract class

public partial class Question 
    { 

     public Question() 
     { 
      this.QuestionOptions = new HashSet<QuestionOption>(); 
     } 

     [DataMember] 
     public int Id { get; set; } 
     [DataMember] 
     public string Description { get; set; } 

     [DataMember] 
     public virtual ICollection<QuestionOption> QuestionOptions { get; set; } 
    } 

感谢您的帮助。

+0

它看起来像服务器无法处理该呼叫。 WCF日志包含什么? –

回答

0

QuestionOption类有一个Question类型的成员,所以在序列化过程中有一个递归调用,所以发生超时。