服务消息大小限制 [英] Service Message Size Limits

查看:70
本文介绍了服务消息大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力解决WCF服务中邮件大小的设置问题。我有一个托管wcf服务的Windows服务。它运行良好,我使用WPF应用程序与它进行通信。


有一次,我在一次服务电话(而不是其他任何电话)上开始收到如下的恐怖:




I am struggling with the settings for message size in WCF services. I have a windows service that hosts a wcf service. It runs great and I use a WPF application to communicate with it.
At one point i start to receive an arror as follows, on a single service call (and not any others):

System.ServiceModel.CommunicationException
HResult=0x80131501
Message=An error occurred while receiving the HTTP response to http://localhost:8001/CAASService/service. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
Source=mscorlib
StackTrace:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

..................

Inner Exception 1:
WebException: The underlying connection was closed: An unexpected error occurred on a receive.

Inner Exception 2:
IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

Inner Exception 3:
SocketException: An existing connection was forcibly closed by the remote host




消息可以更清楚,但我追溯到服务返回消息的大小。我可以在调试服务时确认这一点,并且可以看到函数在接收应用程序
中发生错误之前成功完成。如果我在返回之前从消息中删除了一定数量的子项(一个复杂的对象),那么我就没有错误并且收到的消息很好。



现在,似乎有非常直接的方法来增加消息大小,但是我所尝试过的所有方法都没有任何影响。我的App.Config(客户端和服务器)现在充斥着似乎没有任何影响的设置。



这是我的服务器app.config:




<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime maxRequestLength="51200"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="CAASBinding" messageEncoding="Text" allowCookies="true" maxReceivedMessageSize="52428800" maxBufferSize="52428800" maxBufferPoolSize="52428800" transferMode="Streamed" closeTimeout="00:50:00" openTimeout="00:50:00" sendTimeout="00:50:00" receiveTimeout="00:50:00" >
<readerQuotas maxDepth="52428800" maxStringContentLength="52428800" maxArrayLength="52428800" maxBytesPerRead="52428800"
maxNameTableCharCount="52428800" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="CAASServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="52428800" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="CAASEPBehavior">
<dataContractSerializer maxItemsInObjectGraph="52428800" />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="CAASService.GameService" behaviorConfiguration="CAASServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/CAASService/service" />
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" behaviorConfiguration="CAASEPBehavior" contract="CAASService.IGame" bindingConfiguration="CAASBinding" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>




$
我的客户端app.config:



And my client app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.web>
<httpRuntime maxRequestLength="51200"/>
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="CAASEPBehavior">
<dataContractSerializer maxItemsInObjectGraph="52428800" />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IGame" closeTimeout="00:50:00" messageEncoding="Text"
openTimeout="00:50:00" receiveTimeout="00:50:00" sendTimeout="00:50:00"
allowCookies="true" maxBufferPoolSize="52428800" maxBufferSize="52428800" maxReceivedMessageSize="52428800" transferMode="Streamed" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8001/CAASService/service"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGame"
contract="CAASService.IGame" name="BasicHttpBinding_IGame" behaviorConfiguration="CAASEPBehavior" />
</client>
</system.serviceModel>
</configuration>




我在这里尝试了几种组合(也尝试使用wsHttpBinding),但没有任何影响,我就是越来越不耐烦了。有没有人给我一个提示?


I have attempted several combinations here (also tried using wsHttpBinding), but nothing has the slightest effect and I am growing impatient. Does anyone have a tip for me?

推荐答案

好的,所以我想出来了,它与消息大小无关。问题是基础数据的某些行中的错误,因此无法解析Enum值。

Ok so I figured this out, and it had nothing to do with the message size. The problem was errors in certain rows of the underlying data, so an Enum value could not be resolved.

通过使用以下内容实现此目的:

Achieved this by using the following:

  <system.diagnostics>
    <trace autoflush="true" />
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="sdt"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "SdrConfigExample.e2e" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>




$


这篇关于服务消息大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆