none
WCF Large Image Transfer (>1GB) using TCP transport RRS feed

  • Question

  • I am trying to configure a custom binding for a duplex contract as below:

          <customBinding>
            <binding name="streamedBinding">
              <security allowInsecureTransport="true" />
              <reliableSession flowControlEnabled="true" maxPendingChannels="128" />
              <compositeDuplex />
              <oneWay/>
              <binaryMessageEncoding/>
              <tcpTransport transferMode="Streamed" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"/>
            </binding>
          </customBinding>

    The problem I am having is that I am getting this exception from the service host:

      

    System.InvalidOperationException
      HResult=0x80131509
      Message=The binding ('CustomBinding','http://tempuri.org/') supports streaming which cannot be configured together with message level security.  Consider choosing a different transfer mode or choosing the transport level security.

    Can anyone point me in the direction to help me solve this problem?



    • Edited by DTMSOFT Friday, March 8, 2019 12:51 PM
    Friday, March 8, 2019 12:15 PM

All replies

  • Maybe, you should look into WCF Chunking.
    Friday, March 8, 2019 3:31 PM
  • Hi Dtmsoft,
    Would you mind that tell me why you use Custom binding instead of NetTcpBinding?
    Can we use the following configuration as a replacement?
    <netTcpBinding>
            <binding name="mybinding" transferMode="Streamed" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
              <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
              <security mode="None">
              </security>
            </binding>
          </netTcpBinding>

    Best Regards
    Abraham
    Monday, March 11, 2019 8:35 AM
    Moderator
  • Thanks Abraham. I cannot get it to work with NetTcpBinding but I will try your configuration that you have posted. Have you tried this? Does it work for you?
    Monday, March 11, 2019 11:06 AM
  • Thanks Abraham. I cannot get it to work with NetTcpBinding but I will try your configuration that you have posted. Have you tried this? Does it work for you?

    I don't think it's going to work for you without using  Custom binding to override default settings on the service side.
    Monday, March 11, 2019 5:41 PM
  • Hi, Dtmsoft,

    NetTcpbinding supports duplex communication and reliable session by default, it also works at streamed transfer mode. But I didn't try to work in transfer large file mode, looking forward to your reply.

    Best Regards

    Abraham

    Tuesday, March 12, 2019 2:09 AM
    Moderator
  • Streamed mode does not work using TCP binding with duplex contracts. But will quite happily work in Buffered mode. The problem with this is transferring large images (>500MB) is slow as the message has to sent in its entirety before it can be processed by the service.

    If I was to switch over to using Streamed mode without duplex contracts using TCP, what would a typical binding configuration look like? I also need to run this without security switched on.



    • Edited by DTMSOFT Wednesday, March 20, 2019 12:24 PM
    Wednesday, March 20, 2019 7:59 AM
  • Hi Dtmsoft,
    Do you have solved the problem? please refer to the following link.
    https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/large-data-and-streaming
    In addition, it is unnecessary that we set up the value of the MaxBufferSize/maxBufferPoolSize to over high.
    when transferring the large data, the following code snippets may be useful to you.
    Server end.
    <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="StreamServiceBehavior">
              <serviceMetadata httpGetEnabled="True" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <netTcpBinding>
            <binding name="NewBinding0" transferMode="Streamed"/>
          </netTcpBinding>
        </bindings>
        <services>
          <service behaviorConfiguration="StreamServiceBehavior" name="Service.StreamService">
            <endpoint address="net.tcp://localhost:9000/streamserver" binding="netTcpBinding"
              bindingConfiguration="NewBinding0" bindingName="" contract="Service.IStream" />
            <endpoint address="mex" binding="mexHttpBinding"
              contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8080/StreamService" />
              </baseAddresses>
            </host>
          </service>
        </services>
      </system.serviceModel>
    

    Client end.
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_IStream" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:01:00"
    transferMode="Streamed" 
    listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="4294967295">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://localhost:9000/streamserver" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IStream" contract="Service.IStream"
                name="NetTcpBinding_IStream">
    
            </endpoint>
        </client>
    </system.serviceModel>
    

    Feel free to let me know if there is anything I can help with.
    Best Regards
    Abraham
    Tuesday, March 26, 2019 2:26 AM
    Moderator