title: Duplex Mode StreamedRequest not working with Reliable Session Binding
body: <p>I have been struggling with this for a while and could really use some help. </p>
  
  <p>I am attempting to design a WCF endpoint that allows for the streaming of images to the server and then returns imageURLs (i.e: "<a href="http://images.site.com/someimage.jpg" rel="nofollow noreferrer">http://images.site.com/someimage.jpg</a>"). </p>
  
  <p>Currently, the call to my WCF method looks like this: </p>
  
  <pre><code>for (var i = 0; i &lt;= (Request.Files.Count - 1); i++)
  {
  client = new SOAPFileTransferServiceClient();
  fileinfo = new FileTransferInfo();
  m_objFile = Request.Files[i];
  
  if (!(m_objFile == null | string.IsNullOrEmpty(m_objFile.FileName) |  _objFile.ContentLength &lt; 1))
     {
  
     fileinfo.FileSize = m_objFile.ContentLength;
     fileinfo.FileName = Path.GetFileName(m_objFile.FileName);
     fileinfo.UserID = Context.Request["sid"].ToString();
  
     client.UploadFile(fileinfo, m_objFile.InputStream);
  
     if (retParam.param2 == 0)
     imgurl.Add(retParam.param1);
  
    }
  
  }
  </code></pre>
  
  <p>The error I am struggling with is this: </p>
  
  <blockquote>
    <p>Transfer mode Streamed is not
    supported by
    ReliableSessionBindingElement.</p>
  </blockquote>
  
  <p>So far, I have tried creating a custom netTcp binding with 
  added before the message encoding element. I have also changed my transerMode attribute 
  to streamedRequest (thanks to a suggestion by marc_s) allowing for the request to be streamed but not the response. This seems like it would do the trick but I am still getting the same error (this time "Transfer mode StreamedRequest is not..."). </p>
  
  <p>I am out of ideas. </p>
  
  <p>Below is the file transfer service contract. I have JSON and POX in addition to SOAP endpoints. I also have two MEX endpoints (one for mexHttp and the other for netTcp). Finally, I have both http (for json and pox) and netTcp (for soap) base addresses. </p>
  
  <p>Does anything look wrong? </p>
  
  <pre><code>&lt;service behaviorConfiguration="transferServiceBehavior" name="MyProject.API.FileTransfer.FileTransferService"&gt;
              &lt;endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
                binding="webHttpBinding" bindingConfiguration="jsonWeb" name="MyJSONFileTransferEP"
                contract="MyProject.API.FileTransfer.IJSONFileTransferService" /&gt;
              &lt;endpoint address="pox" behaviorConfiguration="WebHttpEPBehavior"
                binding="webHttpBinding" bindingConfiguration="poxWeb" name="MyPOXFileTransferEP"
                contract="MyProject.API.FileTransfer.IPOXFileTransferService" /&gt;
              &lt;endpoint address="httpMex" binding="mexHttpBinding" bindingConfiguration=""
                contract="IMetadataExchange" /&gt;
              &lt;endpoint address="soap" behaviorConfiguration="NetTcpEPBehavior"
                binding="customBinding" bindingConfiguration="netTcpCustom"
                name="MySOAPFileTransferEP" contract="MyProject.API.FileTransfer.ISOAPFileTransferService" /&gt;
              &lt;endpoint address="nettcpMex" binding="netTcpBinding" bindingConfiguration=""
                contract="IMetadataExchange" /&gt;
              &lt;host&gt;
                &lt;baseAddresses&gt;
                  &lt;add baseAddress="http://localhost:2544/filetransfer/" /&gt;
                  &lt;add baseAddress="net.tcp://localhost:2544/filetransfer/" /&gt;
                &lt;/baseAddresses&gt;
              &lt;/host&gt;
            &lt;/service&gt;
  </code></pre>
  
  <p>And here is my custom binding used by the service contract:</p>
  
  <pre><code>&lt;customBinding&gt;
      &lt;binding name="netTcpCustom"
               closeTimeout="00:01:00"
               openTimeout="00:01:00"
               receiveTimeout="00:10:00"
               sendTimeout="00:01:00"&gt;
        &lt;reliableSession /&gt;
        &lt;compositeDuplex /&gt;
        &lt;oneWay /&gt;
        &lt;windowsStreamSecurity protectionLevel="None" /&gt;
        &lt;mtomMessageEncoding  /&gt;
        &lt;tcpTransport maxBufferPoolSize="524288"
                      maxReceivedMessageSize="2147483647"
                      connectionBufferSize="8192"
                      hostNameComparisonMode="StrongWildcard"
                      channelInitializationTimeout="00:01:00"
                      maxBufferSize="2147483647"
                      maxPendingConnections="20"
                      maxOutputDelay="00:00:00.2000000"
                      maxPendingAccepts="5"
                      transferMode="StreamedRequest"
                      listenBacklog="20"
                      portSharingEnabled="false"
                      teredoEnabled="false"&gt;
          &lt;connectionPoolSettings groupName="default" leaseTimeout="00:05:00"
              idleTimeout="00:02:00" maxOutboundConnectionsPerEndpoint="20" /&gt;
        &lt;/tcpTransport&gt;
      &lt;/binding&gt;
    &lt;/customBinding&gt;
  </code></pre>
  
  <p>Finally, for what it is worth, below is my entire system.serviceModel definition in App.config:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;client&gt;
        &lt;endpoint address="http://localhost:2542/auth/json" behaviorConfiguration="WebHttpEPBehavior"
          binding="webHttpBinding" bindingConfiguration="jsonWeb" contract="Trezoro.WebAPI.Authentication.IJSONAuthService"
          name="MyJSONAuthEP"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2542/auth/pox" behaviorConfiguration="WebHttpEPBehavior"
          binding="webHttpBinding" bindingConfiguration="poxWeb" contract="Trezoro.WebAPI.Authentication.IPOXAuthService"
          name="MyPOXAuthEP"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2542/auth/soap" behaviorConfiguration="BasicHttpEPBehavior"
          binding="basicHttpBinding" bindingConfiguration="soapWeb" contract="Trezoro.WebAPI.Authentication.ISOAPAuthService"
          name="MySOAPAuthEP"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2542/auth/mex" binding="mexHttpBinding"
          bindingConfiguration="" contract="IMetadataExchange" name="authmex"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2543/trade/json" behaviorConfiguration="WebHttpEPBehavior"
          binding="webHttpBinding" bindingConfiguration="jsonWeb" contract="Trezoro.WebAPI.Trade.IJSONTradeService"
          name="MyJSONTradeEP"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2543/trade/pox" behaviorConfiguration="WebHttpEPBehavior"
          binding="webHttpBinding" bindingConfiguration="poxWeb" contract="Trezoro.WebAPI.Trade.IPOXTradeService"
          name="MyPOXTradeEP"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2543/trade/soap" behaviorConfiguration="BasicHttpEPBehavior"
          binding="basicHttpBinding" bindingConfiguration="soapWeb" contract="Trezoro.WebAPI.Trade.ISOAPTradeService"
          name="MySOAPTradeEP"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2543/trade/mex" binding="mexHttpBinding"
          bindingConfiguration="" contract="IMetadataExchange" name="trademex"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2544/filetransfer/json" behaviorConfiguration="WebHttpEPBehavior"
          binding="webHttpBinding" bindingConfiguration="jsonWeb" contract="Trezoro.WebAPI.FileTransfer.IJSONFileTransferService"
          name="MyJSONFileTransferEP"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2544/filetransfer/pox" behaviorConfiguration="WebHttpEPBehavior"
          binding="webHttpBinding" bindingConfiguration="poxWeb" contract="Trezoro.WebAPI.FileTransfer.IPOXFileTransferService"
          name="MyPOXFileTransferEP"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="http://localhost:2545/filetransfer/soap" behaviorConfiguration="NetTcpEPBehavior"
          binding="customBinding" bindingConfiguration="netTcpCustom"
          contract="Trezoro.WebAPI.FileTransfer.ISOAPFileTransferService"
          name="MySOAPFileTransferEP"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
        &lt;endpoint address="net.tcp://localhost:2545/filetransfer/nettcpMex"
          binding="netTcpBinding" bindingConfiguration="" contract="IMetadataExchange"
          name="filetransfermex"&gt;
          &lt;identity&gt;
            &lt;certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
      &lt;/client&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="soapWeb" /&gt;
          &lt;binding name="httpLargeMessageStream"
                   closeTimeout="00:01:00"
                   openTimeout="00:01:00"
                   receiveTimeout="00:10:00"
                   sendTimeout="00:01:00"
                   allowCookies="false"
                   bypassProxyOnLocal="false"
                   hostNameComparisonMode="StrongWildcard"
                   maxBufferSize="2147483647"
                   maxBufferPoolSize="2147483647"
                   maxReceivedMessageSize="2147483647"
                   messageEncoding="Text"
                   textEncoding="utf-8"
                   transferMode="StreamedRequest"
                   useDefaultWebProxy="true"&gt;
            &lt;readerQuotas maxDepth="32"
                          maxStringContentLength="8192"
                          maxArrayLength="16384"
                          maxBytesPerRead="4096"
                          maxNameTableCharCount="16384" /&gt;
            &lt;security mode="None"&gt;
              &lt;transport clientCredentialType="None"
                         proxyCredentialType="None"
                         realm="" /&gt;
              &lt;message clientCredentialType="UserName"
                       algorithmSuite="Default" /&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
        &lt;customBinding&gt;
          &lt;binding name="netTcpCustom"
                   closeTimeout="00:01:00"
                   openTimeout="00:01:00"
                   receiveTimeout="00:10:00"
                   sendTimeout="00:01:00"&gt;
            &lt;reliableSession /&gt;
            &lt;compositeDuplex /&gt;
            &lt;oneWay /&gt;
            &lt;windowsStreamSecurity protectionLevel="None" /&gt;
            &lt;mtomMessageEncoding  /&gt;
            &lt;tcpTransport maxBufferPoolSize="524288"
                          maxReceivedMessageSize="2147483647"
                          connectionBufferSize="8192"
                          hostNameComparisonMode="StrongWildcard"
                          channelInitializationTimeout="00:01:00"
                          maxBufferSize="2147483647"
                          maxPendingConnections="20"
                          maxOutputDelay="00:00:00.2000000"
                          maxPendingAccepts="5"
                          transferMode="StreamedRequest"
                          listenBacklog="20"
                          portSharingEnabled="false"
                          teredoEnabled="false"&gt;
              &lt;connectionPoolSettings groupName="default" leaseTimeout="00:05:00"
                  idleTimeout="00:02:00" maxOutboundConnectionsPerEndpoint="20" /&gt;
            &lt;/tcpTransport&gt;
          &lt;/binding&gt;
        &lt;/customBinding&gt;
        &lt;netTcpBinding&gt;
          &lt;binding name="netTcpWeb"
                   hostNameComparisonMode="StrongWildcard"
                   closeTimeout="00:01:00"
                   openTimeout="00:01:00"
                   receiveTimeout="00:10:00"
                   sendTimeout="00:01:00"
                   maxReceivedMessageSize="2147483647"
                   transferMode="StreamedRequest"
                   portSharingEnabled="false"&gt;
            &lt;security mode="None" /&gt;
          &lt;/binding&gt;
        &lt;/netTcpBinding&gt;
        &lt;webHttpBinding&gt;
          &lt;binding name="poxWeb"
                   maxBufferSize="1500000"
                   maxBufferPoolSize="1500000"
                   maxReceivedMessageSize="1500000"&gt;
            &lt;readerQuotas maxDepth="32"
                          maxStringContentLength="656000"
                          maxArrayLength="656000"
                          maxBytesPerRead="656000"
                          maxNameTableCharCount="656000" /&gt;
          &lt;/binding&gt;
          &lt;binding name="jsonWeb"
                   maxBufferSize="1500000"
                   maxBufferPoolSize="1500000"
                   maxReceivedMessageSize="1500000"&gt;
            &lt;readerQuotas maxDepth="32"
                          maxStringContentLength="656000"
                          maxArrayLength="656000"
                          maxBytesPerRead="656000"
                          maxNameTableCharCount="656000" /&gt;
          &lt;/binding&gt;
        &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="Default" name="Trezoro.WebAPI.Authentication.AuthService"&gt;
          &lt;endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
            binding="webHttpBinding" bindingConfiguration="jsonWeb" name="MyJSONAuthEP"
            contract="Trezoro.WebAPI.Authentication.IJSONAuthService" /&gt;
          &lt;endpoint address="pox" behaviorConfiguration="WebHttpEPBehavior"
            binding="webHttpBinding" bindingConfiguration="poxWeb" name="MyPOXAuthEP"
            contract="Trezoro.WebAPI.Authentication.IPOXAuthService" /&gt;
          &lt;endpoint address="soap" behaviorConfiguration="BasicHttpEPBehavior"
            binding="basicHttpBinding" bindingConfiguration="soapWeb" name="MySOAPAuthEP"
            contract="Trezoro.WebAPI.Authentication.ISOAPAuthService" /&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:2542/auth/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
        &lt;service behaviorConfiguration="Default" name="Trezoro.WebAPI.Trade.TradeService"&gt;
          &lt;endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
            binding="webHttpBinding" bindingConfiguration="jsonWeb" name="MyJSONTradeEP"
            contract="Trezoro.WebAPI.Trade.IJSONTradeService" /&gt;
          &lt;endpoint address="pox" behaviorConfiguration="WebHttpEPBehavior"
            binding="webHttpBinding" bindingConfiguration="poxWeb" name="MyPOXTradeEP"
            contract="Trezoro.WebAPI.Trade.IPOXTradeService" /&gt;
          &lt;endpoint address="soap" behaviorConfiguration="BasicHttpEPBehavior"
            binding="basicHttpBinding" bindingConfiguration="soapWeb" name="MySOAPTradeEP"
            contract="Trezoro.WebAPI.Trade.ISOAPTradeService" /&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:2543/trade/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
        &lt;service behaviorConfiguration="transferServiceBehavior" name="Trezoro.WebAPI.FileTransfer.FileTransferService"&gt;
          &lt;endpoint address="json" behaviorConfiguration="WebHttpEPBehavior"
            binding="webHttpBinding" bindingConfiguration="jsonWeb" name="MyJSONFileTransferEP"
            contract="Trezoro.WebAPI.FileTransfer.IJSONFileTransferService" /&gt;
          &lt;endpoint address="pox" behaviorConfiguration="WebHttpEPBehavior"
            binding="webHttpBinding" bindingConfiguration="poxWeb" name="MyPOXFileTransferEP"
            contract="Trezoro.WebAPI.FileTransfer.IPOXFileTransferService" /&gt;
          &lt;endpoint address="httpMex" binding="mexHttpBinding" bindingConfiguration=""
            contract="IMetadataExchange" /&gt;
          &lt;endpoint address="soap" behaviorConfiguration="NetTcpEPBehavior"
            binding="customBinding" bindingConfiguration="netTcpCustom"
            name="MySOAPFileTransferEP" contract="Trezoro.WebAPI.FileTransfer.ISOAPFileTransferService" /&gt;
          &lt;endpoint address="nettcpMex" binding="netTcpBinding" bindingConfiguration=""
            contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:2544/filetransfer/" /&gt;
              &lt;add baseAddress="net.tcp://localhost:2544/filetransfer/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="WebHttpEPBehavior"&gt;
            &lt;webHttp /&gt;
          &lt;/behavior&gt;
          &lt;behavior name="BasicHttpEPBehavior" /&gt;
          &lt;behavior name="NetTcpEPBehavior" /&gt;
        &lt;/endpointBehaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="Default"&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
          &lt;/behavior&gt;
          &lt;behavior name="transferServiceBehavior"&gt;
            &lt;serviceMetadata httpGetEnabled="true"/&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Any and all suggestions much appreciated. Thanks for your help. </p>