Search code examples
c#wcfvisual-studio-2008httpsbasichttpbinding

WCF Client Https: The underlying connection was closed: An unexpected error occurred on a send


I am trying to invoke a wcf web service from my client application using the protocol https. The web service is running as a windows service. The client is throwing the below exception while calling the web service methods. I also tried using the default port 443.

Inner Exception:

The underlying connection was closed: An unexpected error occurred on a send.

Exception Message:

An error occurred while making the HTTP request to https://myserver.com:1009/TestSvc ". This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.

Client Binding:

<system.serviceModel>
<bindings>
    <basicHttpBinding>
    <binding name="basicHttpBinding_ITest" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    <security mode="Transport"/>
    </binding>
    </basicHttpBinding>
</bindings>

<client>
    <endpoint address="<https://myserver.com:1009/TestSvc>" 
        binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_ITest" contract="ITest" name="basicHttpBinding_ITest">
    </endpoint>
</client>

<behaviors>
<endpointBehaviors>
    <behavior name="ClientCertificateBehavior">
    <clientCredentials>
        <clientCertificate findValue="a7aavvssrrffff400c527eadd528227323e788" storeLocation="Local Machine" storeName="My" x509FindType=" FindByThumbprint"/>
        <serviceCertificate>
            <authentication certificateValidationMode="PeerOrChainTrust" />
        </serviceCertificate>
    </clientCredentials>
    </behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>

Thank You


Solution

  • Try using a Web browser to see if the certificate is considered valid. If its not, then that may be the problem.