我有一个WCF服务(服务器),其中包含签名
的方法public void SetProfilePic(String pSession, Applicant pApplicant)
申请人拥有财产:
public byte[] Photo { get; set; }
从客户端我得到一张图片并调用SetProfilePic。当图像很小,大约1厘米X 1厘米,它完美的工作,但是,当图像较大,4厘米X 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'."
我已经增加了app.config文件中的 max limits ,但是我仍然遇到同样的错误。我在缓冲模式下使用 NetTCPBinding 。我也尝试过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 :(得分: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>