none
InsufficientMemoryException while sending large byte array in WCF Service callback RRS feed

  • Question

  • Hi

    I have a datacontract with a large byte array that is passed by the WCF Service back to the client using a callback contract.


    Until the byte array size remains below 25-30 MB, it is passed OK, but as soon as it exceeds that, an InsufficientMemoryException is thrown on the service side. I have set the max message sizes at 100 MB and using MTOM Encoder.


    I am using WSDualHTTPBinding with sessions and message security - hence streaming is not an option. I know chunking channels are an option, but I want to try to tune the service and client to maximize the byte array size which can be sent over a normal channel.


    Kindly advise how to tune settings to get to around 100 MB byte array size.

    Binding section of web.config is given below. Same settings for sizes are used on client.


    Thanks

    Abhishek


     <wsDualHttpBinding>
            <binding name="WSHttpBinding_IService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="100000000" maxReceivedMessageSize="100000000" messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true">
             
              <readerQuotas maxArrayLength="100000000"  />
            
              <security mode="Message">
             
                <message clientCredentialType="Certificate" algorithmSuite="Default"  />
           
              </security>
            </binding>
          </wsDualHttpBinding>




    Saturday, January 24, 2015 5:19 PM

Answers

  • Hi abhisinghal21,

    >>InsufficientMemoryException while sending large byte array in WCF Service callback

    First please try to increase the timeout value in the both client and service side to see if it works:

    closeTimeout="00:10:00" openTimeout="00:10:00" 
    receiveTimeout="00:10:00" sendTimeout="00:10:00"

    Then since you do not want to the use the Chunking option to help you, maybe you try to change the wsDualHttpBinding to use the binding which supports the streaming mode and supports callback.

    In streaming transfer mode, the receiver can begin to process the message before it is completely delivered. And the streaming mode is useful when the information that is passed is lengthy and can be processed serially. Streaming mode is also useful when the message is too large to be entirely buffered. So it will be better for you to use the streamed mode.

    For more information, please try to check:
    #How to: Enable Streaming:
    http://msdn.microsoft.com/en-us/library/ms789010(v=vs.110).aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Monday, January 26, 2015 7:47 AM
    Moderator
  • You can use the NetTcpbinding.

    Monday, February 2, 2015 1:11 PM

All replies

  • Hi abhisinghal21,

    >>InsufficientMemoryException while sending large byte array in WCF Service callback

    First please try to increase the timeout value in the both client and service side to see if it works:

    closeTimeout="00:10:00" openTimeout="00:10:00" 
    receiveTimeout="00:10:00" sendTimeout="00:10:00"

    Then since you do not want to the use the Chunking option to help you, maybe you try to change the wsDualHttpBinding to use the binding which supports the streaming mode and supports callback.

    In streaming transfer mode, the receiver can begin to process the message before it is completely delivered. And the streaming mode is useful when the information that is passed is lengthy and can be processed serially. Streaming mode is also useful when the message is too large to be entirely buffered. So it will be better for you to use the streamed mode.

    For more information, please try to check:
    #How to: Enable Streaming:
    http://msdn.microsoft.com/en-us/library/ms789010(v=vs.110).aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Monday, January 26, 2015 7:47 AM
    Moderator
  • Hi Amy

    Many Thanks.

    Which binding supports message security, sessions, streaming, duplex contracts and can be hosted in IIS ?

    Regards

    Abhishek


    Monday, January 26, 2015 3:48 PM
  • You can use the NetTcpbinding.

    Monday, February 2, 2015 1:11 PM
  • Hi Idesag, Amy

    Many thanks for the answers.

    The last comment was sort of an eye opener for me - turns out that we cannot even use wsDualHttpBinding because we need to support multiple clients behind a NAT router with duplex channels.

    So now we have switched to NetTcpBinding.

    Best Regards

    Abhishek

    Friday, February 20, 2015 6:13 PM