开发者

Wcf very small packet size

I've enabled wcf basicHttpBinding with TransferMode set to "Streaming".

The problem is every time i do a read operation from the stream on the client side i read exactly 1536 bytes, which is an Ethernet frame.

How can i get my wcf service to send larger packets of data at a time?

EDIT

So, apparently the default BytesPerRead is 4096, however I've changed that value on both the client and the server. here is the config file

Moreover, I've found an unanswered post dealing with the same issue

WCF maxBytesPerRead limit to 4096

Server SERVER

(Note that i have two endpoints, one is for downloading content in basicHttpBinding and one is for communication using ws2007HttpBinding, I am referring to the basicHttpBinding endpoint in my question)

<system.serviceModel>
 <bindings>
   <basicHttpBinding>
     <binding name="MyBasicHttpBinding" allowCookies="true" maxBufferSize="955366"
   maxBufferPoolSize="964285" maxReceivedMessageSize="955556" messageEncoding="Mtom"
   transferMode="Streamed">
   <readerQuotas maxDepth="60" maxStringContentLength="955556" maxArrayLength="955556"
   maxBytesPerRead="955556" maxNameTableCharCount="955556" />
  </binding>
  </basicHttpBinding>
  <ws2007HttpBinding>
  <binding name="MyBinding" allowCookies="false">
   <security mode="None" />
  </binding>
  </ws2007HttpBinding>
 </bindings>
 <services>
  <service behaviorConfiguration="ContentManagementServiceBehavior"
  name="App_Code.Services.ContentManagement.ContentManagementService">
  <clear />
  <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange"
   listenUriMode="Explicit" />
  <endpoint binding="ws2007HttpBinding" bindingConfiguration="MyBinding"
   n开发者_运维技巧ame="ws2007Endpoint" contract="App_Code.Services.ContentManagement.IContentManagementService"
   listenUriMode="Explicit" />
  <endpoint address="/download" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding"
   name="basicHttpBinding" contract="App_Code.Services.ContentManagement.IContentManagementDownlodService" />
  <host>
   <baseAddresses>
   <add baseAddress="/Services/ContentManagement/ContentManagementService.svc" />
   </baseAddresses>
  </host>
  </service>
 </services>
        <behaviors>
  <serviceBehaviors>
  <behavior name="ContentManagementServiceBehavior">
   <serviceMetadata httpGetEnabled="true" />
   <serviceDebug includeExceptionDetailInFaults="true" />
  </behavior>
  </serviceBehaviors>
 </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    </system.serviceModel>

CLIENT

    <system.serviceModel>

  <bindings>

   <basicHttpBinding>

    <binding name="basicHttpBinding" closeTimeout="00:10:00" openTimeout="00:10:00"

     receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"

     bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

     maxBufferPoolSize="92429000" maxReceivedMessageSize="65536000" messageEncoding="Mtom"

     textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true">

     <readerQuotas maxDepth="90" maxStringContentLength="65536000" maxArrayLength="65536000"

      maxBytesPerRead="655360" maxNameTableCharCount="65536000" />

     <security mode="None" />

    </binding>

   </basicHttpBinding>

   <wsHttpBinding>

    <binding name="ws2007Endpoint" closeTimeout="00:01:00" openTimeout="00:01:00"

     receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"

     transactionFlow="false" hostNameComparisonMode="StrongWildcard"

     maxBufferPoolSize="524288646" maxReceivedMessageSize="65536646"

     messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"

     allowCookies="false">

     <readerQuotas maxDepth="32" maxStringContentLength="819264564"

      maxArrayLength="163846764" maxBytesPerRead="40964543" maxNameTableCharCount="16384564" />

     <reliableSession ordered="true" inactivityTimeout="00:10:00"

      enabled="false" />

     <security mode="None">

      <transport realm="" />

     </security>

    </binding>

   </wsHttpBinding>

  </bindings>

  <client>

   <endpoint address="<absolute address>"

    binding="wsHttpBinding" bindingConfiguration="ws2007Endpoint"

    contract="ContentManagementServiceReference.IContentManagementService"

    name="ws2007Endpoint" />

   <endpoint address="<absolute address>"

    binding="basicHttpBinding" bindingConfiguration="basicHttpBinding"

    contract="ContentManagementServiceReference.IContentManagementDownlodService"

    name="basicHttpBinding" />

  </client>

 </system.serviceModel>


Take a look on this thread: http://social.msdn.microsoft.com/forums/en-US/wcf/thread/e1f7b040-39a8-4ca8-9def-96b2b47c0d6f/

There are couple options there that I think will be a good fit for your issue.

Thanks,

Roberto.


You can try to change maxBytesPerRead property:

<bindings>
    <basicHttpBinding>
        <binding name="Streamed" TransferMode="Streamed" TextEncoding="Mtom"
            maxMessageReceivedSize="4000000">
            <readerQuotas mexBytesPerRead="8192" />
        </binding>
    </basicHttpBinding>
</bindings>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜