The remote server returned an error: (417) Expectation Failed
- Dominant language
- C#
- Stars
- 1.8k
- Forks
- 576
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 2
Description
We're trying to connect from a Backendservice made with NET Core 3.1 to a legacy WCF Service. For this we use the two NuGet packages "System.ServiceModel.Http" and "System.ServiceModel.Primitives" (latest version 4.8.1).
For the connection to the endpoint we create the binding/serviceclient manual as follows:
```
var binding = new BasicHttpsBinding();var endpoint = new EndpointAddress(new Uri("ENDPOINT"));
binding.Security.Mode = BasicHttpsSecurityMode.Transport;
binding.Security.Transport = new HttpTransportSecurity() { ClientCredentialType = HttpClientCredentialType.Certificate, ProxyCredentialType = HttpProxyCredentialType.Basic };
binding.CloseTimeout = new TimeSpan(0, 12, 0, 0, 0);
binding.OpenTimeout = new TimeSpan(0, 12, 0, 0, 0);
binding.SendTimeout = new TimeSpan(0, 12, 0, 0, 0);
binding.MaxReceivedMessageSize = 2147483646;
binding.MaxBufferSize = 2147483646;
var channelfactory = new SearchServiceClient(binding, endpoint);
channelfactory.ClientCredentials.ClientCertificate.SetCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser, System.Security.Cryptography.X509Certificates.StoreName.My, System.Security.Cryptography.X509Certificates.X509FindType.FindBySubjectName, "CERTIFICATENAME");
var response = await channelfactory.existsAsync(...);
```
In order to establish the connection we need to use an SSL client certificate, not a username/password.
With each request we receive the following error message: "The remote server returned an error: (417) Expectation Failed".
I did some research and found out that all you need to do is set the "ExpectContinue" flag to false.
`ServicePointManager.Expect100Continue = false;`
Unfortunately this does not work via the ServicePointManager (not even in web.config).
if I downgrade the nuget package version of "System.ServiceModel.Http" and "System.ServiceModel.Primitives" to **4.4.4**, it works.
Does anyone know how I can do this with the latest version ?
Contributor guide
Assessment
This issue has not been assessed yet.