The socket connection was aborted - CommunicationException

后端 未结 7 699
我寻月下人不归
我寻月下人不归 2020-12-08 10:54

Originally:

  • I thought this was a circular reference problem........turns out it\'s not.
  • The problem arose from having not configured
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 11:19

    Had this problem with a long intialisation process that was being called from the OnStart event of a Windows Service Host installer. Fixed by setting the security mode and timeouts for the TCP binding.

                // Create a channel factory.
                NetTcpBinding b = new NetTcpBinding();
                b.Security.Mode = SecurityMode.Transport;
                b.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
                b.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
    
                b.MaxReceivedMessageSize = 1000000;
                b.OpenTimeout = TimeSpan.FromMinutes(2);
                b.SendTimeout = TimeSpan.FromMinutes(2);
                b.ReceiveTimeout = TimeSpan.FromMinutes(10);
    

提交回复
热议问题