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.
I have set the address with 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. But it could not be discovery by 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. 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. But I am not sure why I need this, my application has already configured Udp protocol in firewall.