首页 文章

限制WCF服务中的客户端连接

提问于
浏览
0

我创建了一个WCF服务并将其托管在控制台应用程序中 . 我有2个客户端应用程序将与该WCF服务进行通信,现在我想限制3个客户端连接到此WCF服务 .

有没有办法拒绝第三个客户端的服务器端连接?或者,在与客户 Build 之前,服务器是否可以验证连接?

服务器端代码

Uri httpBaseAddress = new Uri("net.pipe://localhost/ServiceHost/ServiceHost"); 
studentServiceHost.AddServiceEndpoint(typeof(StudentService.IStudentService), binding, httpBaseAddress); 
studentServiceHost.Open()

1 回答

  • 1

    如果要同时从连接到服务停止3个客户端,可以使用绑定的maxConnections属性,将其设置为2 .

    如果您只希望特定客户端访问您的服务 . 然后,您需要设置身份验证,请参阅:WCF self hosting require authentication

相关问题