tags:

views:

359

answers:

3

Hi.

I am designing a duplex channel wcf service using a custom binding. Currently, when I compile my class library, I am getting the following error:

Transfer mode Streamed is not supported by ReliableSessionBindingElement.

Below is my App.config:

<service behaviorConfiguration="transferServiceBehavior" 
               name="API.FileTransfer.FileTransferService">
        <endpoint address="json" 
                  behaviorConfiguration="WebHttpEPBehavior"
                  binding="webHttpBinding" 
                  bindingConfiguration="jsonWeb" 
                  name="MyJSONFileTransferEP"
                  contract="API.FileTransfer.IJSONFileTransferService" />
        <endpoint address="pox" 
                  behaviorConfiguration="WebHttpEPBehavior"
                  binding="webHttpBinding" 
                  bindingConfiguration="poxWeb" 
                  name="MyPOXFileTransferEP"
                  contract="API.FileTransfer.IPOXFileTransferService" />
        <endpoint address="soap" 
                  behaviorConfiguration="NetTcpEPBehavior"
                  binding="netTcpBinding" 
                  bindingConfiguration="netTcpWeb" 
                  name="MySOAPFileTransferEP"                   
                contract="API.FileTransfer.ISOAPFileTransferService" />
        <endpoint address="mex" 
                  binding="mexTcpBinding" 
                  bindingConfiguration=""
                  contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:2544/filetransfer/" />
            <add baseAddress="net.tcp://localhost:2544/filetransfer/" />
          </baseAddresses>
        </host>
</service>

The error I am getting is referring to my custom binding which has both reliableSession and compositeDuplex binding elements:

<customBinding>
    <binding name="netTcpCustom" 
             closeTimeout="00:01:00"
             openTimeout="00:01:00"
             receiveTimeout="00:10:00"
             sendTimeout="00:01:00">
      <reliableSession />
      <compositeDuplex />
      <oneWay />
      <windowsStreamSecurity protectionLevel="None" />
      <mtomMessageEncoding  />
      <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="Streamed" 
                    listenBacklog="20"
                    portSharingEnabled="false" 
                    teredoEnabled="false">
        <connectionPoolSettings groupName="default" leaseTimeout="00:05:00"
            idleTimeout="00:02:00" maxOutboundConnectionsPerEndpoint="20" />
      </tcpTransport>
    </binding>
  </customBinding>

After some searching, I found out that you cannot use streaming when using reliable messaging (WS-RM). This is because WS-RM needs to apply signing/checksums to the whole message as a unity, etc; and this is not possible when streamed transferMode, only with buffered transferMode.

Since I am designing a duplex binding channel and I am using this service for the upload of large files, i need transferMode = streamed AND the reliable session binding element.

Does anybody know how to attack this? Can you show me how it is done?

Thanks in advance.

A: 

If you turn on security (e.g. SecurityMode=something other than None) you'll get a session on NetTcpBinding, I believe. There may also be other knobs to provide a session, or you could create a custom binding with tcp as a transport and reliableSession as a binding element. I don't recall all the details, but hopefully those are some starters.

Oh no wait, there's a knob for it:

http://msdn.microsoft.com/en-us/library/system.servicemodel.nettcpbinding.reliablesession.aspx

See also

http://blogs.msdn.com/drnick/archive/2006/06/05/617703.aspx

Brian
Thanks Brian. I had a go at your custombinding suggestion and updated my question with the results. Anything in my config that looks fishy?
Code Sherpa
Brian - any further suggestions per my question's updates? Thanks again.
Code Sherpa
A: 

We have built a system where the users can upload and download very large files, without using streaming.

The main reason to use streaming is that it is memory efficient.

The only thing that you really need to make it work is lots of RAM. You should also make sure that you dispose of all objects correctly as in this case memory leaks will cause problems.

Shiraz Bhaiji
Thanks Shiraz, would be curious exactly what you did. But, for our immediate purposes, we really need a solution to the posted problem as a lot of time and effort has already gone into the current architecture.
Code Sherpa
We just had servers with enough RAM. This is a bit simplified but, say you have 100 users downloading a 10 MB file at the same time. That is just 1 GB in memory, if you have a 16 GB server no problems.
Shiraz Bhaiji
OK, thanks. Makes sense. Well, for now, we are going to focus on the current architecture so, if you have any ideas, please let me know! Thanks for your input.
Code Sherpa
+1  A: 

I am starting to think that the answer to this question may be "not possible".

I have checked MSDN and numerous forums and they all lead to a dead end. Seems streaming without reliableSession is possible or the other way around but so far I haven't been able to find an example of the combination of the two.

Code Sherpa
judging by the lack of replies to this question (and lack of content on the Internet) I am guessing that I will be marking "not possible" as the answer. I'll leave this up for a few more days, just in case...
Code Sherpa