WCF CustomBinding Duplex Fails to Open Client port

By : Bhuvan
Source: Stackoverflow.com
Question!

I am struggling with this duplex WCF service which makes calls to the service to get large amounts of data. I am using wsDualHttpBinding which works but is very slow. I profiled and most time is being used by Serializers and authentication process. So I decided to use Binary Encoding and change the Security to Transport and since it is an intranet application, encryption is not that necessary.

<wsDualHttpBinding>
        <binding name="CRMXServiceDualBinding" sendTimeout="00:10:00"
          maxBufferPoolSize="50524288" maxReceivedMessageSize="50000000"
          messageEncoding="Mtom">
          <readerQuotas maxDepth="50000000" maxStringContentLength="50000000"
            maxArrayLength="50000000" maxBytesPerRead="50000000" maxNameTableCharCount="50000000" />
          <reliableSession ordered="true" inactivityTimeout="00:30:00" />
          <security mode="Message">
            <message clientCredentialType="Windows" negotiateServiceCredential="true" />
          </security>
        </binding>
      </wsDualHttpBinding>

So I tried to compose this Custom binding.

<customBinding>
        <binding name="DuplexBindingConfig">
          <compositeDuplex />
          <oneWay maxAcceptedChannels="128" packetRoutable="false">
            <channelPoolSettings idleTimeout="00:10:00" leaseTimeout="00:10:00"
              maxOutboundChannelsPerEndpoint="10" />
          </oneWay>
          <binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
              maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          </binaryMessageEncoding>
          <httpTransport manualAddressing="false" maxBufferPoolSize="2147483647"
            maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Negotiate"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
            realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
            useDefaultWebProxy="true" />
        </binding>
      </customBinding>

Now I am facing two problems: 1. To test on ASP.Net development server it immediately returns the error: "The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'NTLM'." 2. Testing on IIS6, the call never reaches the server. My Hunch is that the Client port is not being opened.

Please Help.. Thanks in advance.

*BTW i am using Windows XP SP3, Framework 3.5 SP1, VS2008

By : Bhuvan


Answers
I can see one problem:

You cannot use transport level security on a duplex http binding, even a custom duplex http binding.

The client will listen through a generic port listener (that is, one that is not a Web Service) and will not understand the details that are required to make SSL work.



This video can help you solving your question :)
By: admin