2015-10-20 75 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