简体   繁体   English

在IIS上发布后,WCF发现UDPEndpoint无法正常工作

[英]WCF Discovery UDPEndpoint did not work after published on IIS

I made a test with WCF Discovery UDPEndpoint, it works at my own computer, but if I publish it to IIS, and then call it from other computers, it could not be found. 我使用WCF Discovery UDPEndpoint进行了测试,它可以在我自己的计算机上运行,​​但是如果我将它发布到IIS,然后从其他计算机调用它,则无法找到它。

I have set the address with IP. 我用IP设置了地址。

Service 服务

using (ServiceHost host = new ServiceHost(typeof(DiscoveryProxy), new Uri("http://xx.xxxx.xxx.xxx:8080/DiscoveryProxy")))
{
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    host.Description.Behaviors.Add(smb);
    ServiceEndpoint sep= host.AddServiceEndpoint(typeof(IDiscoveryProxy),new BasicHttpBinding(),"");
    sep.ListenUri = new Uri("http://xx.xxxx.xxx.xxx:8080/DiscoveryProxy/via");
    ServiceDiscoveryBehavior sdb = new ServiceDiscoveryBehavior();
    sdb.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint());
    host.Description.Behaviors.Add(sdb);
    host.AddServiceEndpoint(new UdpDiscoveryEndpoint());

    host.Open();
    Console.WriteLine("service is open");
    Console.ReadLine();
    host.Close();
}

The service reference is added correctly at Client, and I could browse the service from IE. 在客户端正确添加服务引用,我可以从IE浏览服务。 But it could not be discovery by UDP. 但它无法通过UDP发现。

Client 客户

    DiscoveryClient client = new DiscoveryClient(new UdpDiscoveryEndpoint());
    FindResponse response = client.Find(new FindCriteria(typeof(myDiscoveryProxy)));
    if (response.Endpoints.Count > 0)
    {
        EndpointAddress address = response.Endpoints[0].Address;
        Console.WriteLine("service address is " + address);
        ServiceReference2.myDiscoveryProxyClient service = new ServiceReference2.myDiscoveryProxyClient(new BasicHttpBinding(), address);
        service.getString("discovery proxy");
    }

I have opened the UDP port both in client and service. 我在客户端和服务中都打开了UDP端口。 Is there any way to troubleshooting this issue? 有没有办法解决这个问题?

It seems I have achieved my requirements. 看来我已经达到了我的要求。 I configure firewall in my Service side. 我在服务端配置防火墙。 Windows Firewall with Advanced Security->Inbound Rules->New Rule->Port->UDP->All local ports->Allow the connection->Domain,Private,Public->Name for this rule. 具有高级安全性的Windows防火墙 - >入站规则 - >新规则 - >端口 - > UDP->所有本地端口 - >允许此规则的连接 - >域,专用,公共 - >名称。 But I am not sure why I need this, my application has already configured Udp protocol in firewall. 但我不知道为什么我需要这个,我的应用程序已经在防火墙中配置了Udp协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM