У меня 2 сервера. На каждом из них установлена одна служба WCF. Клиент подключается к сервисам через балансировщик нагрузки. Балансировщик нагрузки распределяет запросы на эти 2 сервера. Когда балансировщик нагрузки перенаправляет запрос на тот же сервер, на котором находится клиент, возникает ошибка безопасности. Когда балансировщик нагрузки перенаправляет запрос на другой сервер, все работает нормально. Ошибка:
System.ServiceModel.Security.SecurityNegotiationException: The server has rejected the client credentials.
---> System.Security.Authentication.InvalidCredentialException: The server has rejected the client credentials.
---> System.ComponentModel.Win32Exception: The logon attempt failed
--- End of inner exception stack trace ---
at System.Net.Security.NegoState.EndProcessAuthentication(IAsyncResult result)
at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.InitiateUpgradeAsyncResult.OnCompleteAuthenticateAsClient(IAsyncResult result)
at System.ServiceModel.Channels.StreamSecurityUpgradeInitiatorAsyncResult.CompleteAuthenticateAsClient(IAsyncResult result)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass7_0`1.<CreateGenericTask>b__0(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
Конфигурации следующие:
<binding name="bindingName"
receiveTimeout="02:00:00"
sendTimeout="02:00:00"
maxBufferPoolSize="1524288"
maxReceivedMessageSize="20553600">
<readerQuotas maxArrayLength="1024000000" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
<endpoint
address="net.tcp://localhost:5555/endpoint"
binding="netTcpBinding"
bindingConfiguration="bindingName"
contract="IContract">
<identity>
<dns />
</identity>
</endpoint>
<behavior name="behaviorName">
<serviceMetadata httpGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
<serviceThrottling maxConcurrentCalls="128000"
maxConcurrentSessions="128000"
maxConcurrentInstances="128000" />
</behavior>