Reputation: 11
I have one client machine and two server machines. The system of the server machine is the same. Server machine Windows Server 2019 Standard, Version:1809 .Net Framework 4.7 Advanced Service -> TCP Port Sharing open Client machine Windows 11 Pro, Version: 21H2 .Net Framework 4.8 Advanced Service -> TCP Port Sharing open The WCF client side code is as follows //Client side code: NetTcpBinding bindings = new NetTcpBinding; bindings.MaxReceivedMessageSize = 2147483647; bindings.Security.Mode = SecurityMode.Transport; string addr = "net.tcp://10.224.11.11:12345/MyTCPService"; EndpointAddress address = new EndpointAddresss(new Uri(addr), EndpointIdentity.CreateSpnIdentity("")); ChannelFactory<MyTCPService.IDBAgent> myFactory = new ChannelFactory<MyTCPService.IDBAgent>(bindings, address); MyTCPService.IDBAgent channel = myFactory.CreateChannel(); CommunicationState state = ((IClientChannel)channel).State; if (state == CommunicationState.Created) { ((IClientChannel)channel).Open(); }
//Server side code:
string addr = "net.tcp://localhost:12345/MyTCPService";
ServiceHost serHost = new ServiceHost(typeof(DataAgent), new Uri(addr));
NetTcpBinding bindings = new NetTcpBinding;
bindings.CloseTimeout = TimeSpan.Parse("00:01:00");
bindings.OpenTimeout = TimeSpan.Parse("00:01:00");
bindings.ReceiveTimeout = TimeSpan.Parse("00:01:00");
bindings.SendTimeout = TimeSpan.Parse("00:01:00");
bindings.TransactionFlow = false;
bindings.TransferMode = TransferMode.Buffered;
bindings.MaxBufferPoolSize = 1024;
bindings.MaxBufferSize = 1073741824;
bindings.MaxReceivedMessageSize = 1073741824;
bindings.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
bindings.ReaderQuotas.MaxDepth = 64;
bindings.ReaderQuotas.MaxArrayLength = 2147483647;
bindings.ReaderQuotas.MaxStringContentLength = 2147483647;
bindings.ReaderQuotas.MaxNameTableCharCount = 2147483647;
bindings.ReaderQuotas.MaxBytesPerRead = 2147483647;
bindings.ReliableSession.InactivityTimeout = TimeSpan.Parse("00:05:00");
bindings.ReliableSession.Ordered = true;
bindings.ReliableSession.Enabled = false;
bindings.Security.Mode = SecurityMode.Transport;
ServiceThrottlingBehavior throttling = new ServiceThrottlingBehavior
{
MaxConcurrentCalls = 500,
MaxConcurrentInstances = 500,
MaxConcurrentSessions = 500
};
ServiceMetadataBehavior metadata = new ServiceMetadataBehavior
{
HttpGetEnabled = false
};
serHost.Description.Behaviors.Add(throttling);
serHost.Description.Behaviors.Add(metadata);
serHost.AddServiceEndpoint(typeof(IDBAgent), bindings, addr);
serHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBindings(), addr);
Questions: The problem I encountered is that one of the two server machines cannot communicate with the client. I checked that the binding port and address are correct and the machine is in the same domain. I don't know what account Windows uses to establish communication. Is there any way to know? Why can't I open the channel? The socket connection was aborted when the client executed channel Open() function Is there a way to obtain the certificate name of Windows authentication so that I can check whether the client and server of WCF match the certificate? What I do I checked that the binding port and address are correct and the machine is in the same domain. If I change Client to bindings Security Mode to None; Then you can connect to the server machine that failed to connect before, so I suspect that the Windows permissions of this machine have special settings, but I don't know where to find the settings.
Upvotes: 1
Views: 341
Reputation: 11
Finally, I found that it was the problem of the login user I served. I used LOCAL SERVICE, so I did not have access rights.
Upvotes: 0
Reputation: 11
The error message is : The socket connection was aborted. this could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue.
It was my fault. Now I find that the client is in the Win11 system and the server is in Windows Server 2019. In this case, using the above code, WCF connection will fail. If Client and Server are on the same Windows version, then the connection will succeed.
Upvotes: 0