2015-10-20 57 views
0

我与谁的签名的方法WCF服务(服务器)发送文件到WCF服务,插座连接中止

public void SetProfilePic(String pSession, Applicant pApplicant) 

申请人具有这样的特性:

public byte[] Photo { get; set; } 

从客户端,我得到一个图像并调用SetProfilePic。当图像小,大约厘米×1厘米,它完美的作品,然而,当图像较大,站着,4cm×3厘米,我得到下面

"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 '01:49:59.9779945'." 

我已经在应用程序增加了最大限制错误.config文件,但是我仍然得到相同的错误。我正在使用NetTCPBinding in 缓冲模式。我也尝试过MTOM。由于项目仍处于初始开发阶段,因此客户端和服务目前都在同一台计算机上运行。

我在服务器和客户端都启用了消息日志记录和跟踪功能,但是日志中没有提供进一步的细节,这不是很有帮助。

下面请找到客户端和服务器的App.config文件。

我的WCF体验只有几个月。任何帮助表示赞赏。提前致谢。

客户端的app.config

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.diagnostics> 
     <sources> 
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing"> 
       <listeners> 
        <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
         <filter type="" /> 
        </add> 
        <add name="ServiceModelMessageLoggingListener"> 
         <filter type="" /> 
        </add> 
       </listeners> 
      </source> 
      <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing"> 
       <listeners> 
        <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
         <filter type="" /> 
        </add> 
        <add name="ServiceModelTraceListener"> 
         <filter type="" /> 
        </add> 
       </listeners> 
      </source> 
     </sources> 
     <sharedListeners> 
      <add initializeData="c:\users\...\app_messages.svclog" 
       type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
       name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp"> 
       <filter type="" /> 
      </add> 
      <add initializeData="c:\users\...\app_tracelog.svclog" 
       type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
       name="ServiceModelTraceListener" traceOutputOptions="Timestamp"> 
       <filter type="" /> 
      </add> 
     </sharedListeners> 
    </system.diagnostics> 
    <system.serviceModel> 
     <diagnostics> 
      <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" 
       logMessagesAtTransportLevel="true" /> 
     </diagnostics> 
     <bindings> 
      <netTcpBinding> 
       <binding name="NetTcpBinding" closeTimeout="01:50:00" openTimeout="01:50:00" 
        receiveTimeout="01:50:00" sendTimeout="01:50:00" maxBufferPoolSize="2147483647" 
        maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> 
        <readerQuotas maxDepth="128" maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
        <reliableSession inactivityTimeout="00:20:00" /> 
       </binding> 
      </netTcpBinding> 
     </bindings> 
     <client> 
      <endpoint address="net.tcp://localhost:9000/RecruitAidService" 
       behaviorConfiguration="endpointBehavior" binding="netTcpBinding" 
       bindingConfiguration="NetTcpBinding" contract="RecruitAidClientService.IRecruitAidService" 
       name="NetTcpBinding" /> 
     </client> 
     <behaviors> 
     <endpointBehaviors> 
      <behavior name="endpointBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
      </behavior> 
     </endpointBehaviors> 
     </behaviors> 
    </system.serviceModel> 
</configuration> 

服务/服务器的app.config

UpdateApplicantUpdateBy(pSession, applId); 

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    </configSections> 
    <system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing"> 
     <listeners> 
      <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
      <filter type="" /> 
      </add> 
      <add name="ServiceModelMessageLoggingListener"> 
      <filter type="" /> 
      </add> 
     </listeners> 
     </source> 
     <source propagateActivity="true" name="System.ServiceModel" switchValue="Verbose,ActivityTracing"> 
     <listeners> 
      <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
      <filter type="" /> 
      </add> 
      <add name="ServiceModelTraceListener"> 
      <filter type="" /> 
      </add> 
     </listeners> 
     </source> 
    </sources> 
    <sharedListeners> 
     <add initializeData="c:\users\...\app_messages.svclog" 
     type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
     name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp, Callstack"> 
     <filter type="" /> 
     </add> 
     <add initializeData="c:\users\...\app_tracelog.svclog" 
     type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
     name="ServiceModelTraceListener" traceOutputOptions="Timestamp"> 
     <filter type="" /> 
     </add> 
    </sharedListeners> 
    </system.diagnostics> 
    <runtime> 
    <loadFromRemoteSources enabled="true"/> 
    </runtime> 
     <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <diagnostics> 
     <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <services> 
     <service name="RecruitAidServer.RecruitAidService"> 
     <clear /> 
     <endpoint address="net.tcp://localhost:9000/RecruitAidService" 
      binding="netTcpBinding" bindingConfiguration="" name="NetTcpBinding" 
      contract="RecruitAidServer.IRecruitAidService" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8733/Design_Time_Addresses/RecruitAidServer/Service1/" /> 
      </baseAddresses> 
      <timeouts closeTimeout="00:01:50" /> 
     </host> 
     </service> 
    </services> 

    <bindings> 
     <basicHttpBinding> 
     <binding name="NetTcpBinding" closeTimeout="01:50:00" openTimeout="01:50:00" 
      receiveTimeout="01:50:00" sendTimeout="01:50:00" maxBufferPoolSize="21474836470000" 
      maxBufferSize="2147483647" maxReceivedMessageSize="21474836470000" 
      transferMode="Buffered" messageEncoding="Mtom"> 
      <readerQuotas maxDepth="128" maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" /> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="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> 
     <endpointBehaviors> 
     <behavior name="endpointBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    </system.serviceModel> 

</configuration> 
+0

奇怪,配置看起来不错。我唯一提到的:在服务器端** endpointBehavior **没有真正应用于服务,因为没有指定behaviorConfiguration。 – Mimas

+0

与''bindingConfiguration''相同,它是空的。您应该将其设置为** NetTcpBinding **。我也没有得到你使用的绑定。您已配置basicHttpBinding,但服务使用netTcpBinding – Mimas

回答

0

服务在服务器端的配置应该像

<endpoint address="net.tcp://localhost:9000/RecruitAidService" 
    binding="netTcpBinding" bindingConfiguration="NetTcpBinding" 
    name="NetTcpBinding" behaviorConfiguration="endpointBehavior" 
    contract="RecruitAidServer.IRecruitAidService" /> 

和绑定

<bindings> 
    <netTcpBinding> 
    <binding name="NetTcpBinding" closeTimeout="01:50:00" openTimeout="01:50:00" 
     receiveTimeout="01:50:00" sendTimeout="01:50:00" maxBufferPoolSize="21474836470000" 
     maxBufferSize="2147483647" maxReceivedMessageSize="21474836470000" 
     transferMode="Buffered" messageEncoding="Mtom"> 
     <readerQuotas maxDepth="128" maxStringContentLength="2147483647" 
     maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" /> 
    </binding> 
    </netTcpBinding> 
</bindings> 
+0

非常感谢Mimas的帮助。您提供的上述配置解决了问题。我也删除了messageEncoding =“Mtom” 再次感谢。 – DreX