We have two different networks in our company, 17 and 18
On the 17 network there is a WCF service running which is discoverable. This is configured by the following code:
host.AddDefaultEndpoints();
host.AddServiceEndpoint(new UdpDiscoveryEndpoint());
EndpointDiscoveryBehavior behavior = new EndpointDiscoveryBehavior();
behavior.Scopes.Add(scope);
foreach(ServiceEndpoint endpoint in host.Description.Endpoints)
{
if(endpoint.IsSystemEndpoint || endpoint is DiscoveryEndpoint ||
endpoint is AnnouncementEndpoint || endpoint is ServiceMetadataEndpoint)
continue;
endpoint.Behaviors.Add(behavior);
}
A behavior with a scope is added to all non system endpoints and it can be discovered by sending udp packets over the network, a default instance of UdpDiscoveryEndpoint.
Clients discover the service by constructing a DiscoveryClient with a default UdpDiscoveryEndpoint.
DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint());
FindCriteria criteria = new FindCriteria(typeof(T));
criteria.Scopes.Add(scope);
FindResponse discovered = discoveryClient.Find(criteria);
discoveryClient.Close();
This works fine when both client and service run on the same network. But I would like to have a client running on the 18 network which is able to find the service on the 17 network.
So is it possible to discover services on other networks with DiscoveryClient and UdpDiscoveryEndpoint?
edit
Or can this be a firewall issue?
This is not a firewall issue but normal behavior of WS-Discovery. WS-Discovery uses SOAP-over-UDP sent to multicast IP group (239.255.255.250). And multicast packets generally are not routed and stay within limits of local network. Thus DiscoveryClient cannot discover services on other network without external help.
You have two options: