I used Connected Service to use WSDL, that generates CurrencyClient proxy in Visual Studio.
Then I'm registering CurrencyClient as singleton:
services.AddSingleton(() =>
{
var binding = new BasicHttpsBinding();
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var address = new EndpointAddress("XXX");
var client = new CurrencyClient(binding, address);
client.ClientCredentials.UserName.UserName = "XXX";
client.ClientCredentials.UserName.Password = "XXX";
return client;
});
And in multiple places where I have to use this service I'm injecting CurrencyCient and using it like this:
var channel = _currencyClient.ChannelFactory.CreateChannel();
channel.InvokeSomeMethod();
channel.Close();
The problem is that it works for many requests, but after some hours I got:
System.ServiceModel.Security.SecurityNegotationException: Could not establish trust relationship for the SSL/TLS secure channel with authority XXX, ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.ComponentModel.Win32Exception: The buffers supplied to a function was too small.
What I'm pretty sure, is that it's definetely the code problem, because while I got this error I can easily request the service from SoapUI or another program and got results.
