我创建了一个WCF服务并将其托管在控制台应用程序中。我有2个客户端应用程序将与该WCF服务进行通信,现在我想限制3个客户端连接到此WCF服务。
有没有办法拒绝服务器端第三个客户端的连接? 或者是否有任何方式服务器可以在建立之前验证连接 客户端?
服务器端代码
Uri httpBaseAddress = new Uri("net.pipe://localhost/ServiceHost/ServiceHost");
studentServiceHost.AddServiceEndpoint(typeof(StudentService.IStudentService), binding, httpBaseAddress);
studentServiceHost.Open()
答案 0 :(得分:1)
如果要同时将3个客户端从Connection连接到服务,可以使用绑定的maxConnections属性,将其设置为2.
如果您只希望特定客户端访问您的服务。然后,您需要设置身份验证,请参阅:WCF self hosting require authentication