Opening Service Host with attached AnnouncementEndpoint fails RRS feed

  • Question

  • Hi there,

    I have a self hosted WCF Host (hosted inside a Windows Service) to which I attach a ServiceDiscoveryBehavior and a UdpAnnouncementEndpoint like this (and of course some "working" endpoints which I omitted for brevity):

    if (WCFHost.Description.Behaviors.Find<ServiceDiscoveryBehavior>() == null)
      ServiceDiscoveryBehavior DiscoveryBehavior = new ServiceDiscoveryBehavior();
      DiscoveryBehavior.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint());
      WCFHost.AddServiceEndpoint(new UdpDiscoveryEndpoint());
    // add other endpoints to the Host

    With this, all "working" endpoints announce themselves when I call the WCFHost.Open() function as expected.

    The problem now is, that opening this service host takes place the moment some hardware (USB, self powered, connected to the machine) is switched on - in that moment that the OS recognizes the Hardware (that is: triggered by a Device-Changed Message). Unfortunately, another hardware (Ethernet, that is also connected to the machine) gets switched on at the same moment, which causes the OS to start some address resolution traffic to that hardware - as can be seen on this Wireshark capture protocol for that network interface:

    The Service-Trace of opening the above mentioned WCFHost tells me, that I called the Open() function at 07:40:26:600, which is (as far as I understand it) while the OS was busy negotiating with the just switched on ethernet-hardware.

    In this case OnlineAnnouncementChannelDispatcher failed to open, which in succession causes my complete WCFHost to fail opening - as can be seen in this ServiceTrace:

    I already tried increasing the MaxAnnouncementDelay-member of the UdpAnnouncementEndpoint (to 5 seconds), which did not help (and which I do not want anyway).

    The Exception I get is:

    Unerwartete Socketausnahme beim Senden von Daten. Details finden Sie in der inneren Ausnahme. ---> 
    System.Net.Sockets.SocketException: Der Host war bei einem Socketvorgang nicht erreichbar
       bei System.Net.Sockets.Socket.EndSendTo(IAsyncResult asyncResult)
       bei System.ServiceModel.Channels.UdpSocket.SendToAsyncResult.OnSendToComplete(IAsyncResult result)
       --- Ende der internen Ausnahmestapelüberwachung ---
    Server stack trace: 
       bei System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
       bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
       bei System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
       bei System.ServiceModel.Channels.ServiceChannelProxy.InvokeEndService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       bei System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       bei System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
       bei System.ServiceModel.Discovery.OnlineAnnouncementChannelDispatcher.OnOpen(TimeSpan timeout)
       bei System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       bei System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
       bei System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       bei System.ServiceModel.Channels.CommunicationObject.Open()
       bei myWCFHost.OpenWcfHost()

    (as you see, I have a german OS, the inner exception translates to: A socket operation was attempted to an unreachable host.)

    Is there a chance that I can have the automatic announcement I want while also having a network "popping up" at the same time (which I can not really avoid) ?

    Or can I "limit" the announcement to all network interfaces except the one which is "starting up" ??

    By the way:

    • This only happens the first time, that the network is activated (i.e. after booting the machine or after Disabling/Enabling the network interface). The second time the ethernet hardware gets switched on, it seems like the OS is faster with "setting up" the network - at least it looks like this in another Wireshark protocol (the second time, I see only two ARP packages, within approx. 300ms after powering up the ethernet HW)
    • I reproduced this on two different machines, both Windows 7

    Any help would be greatly appreciated !

    Thursday, February 5, 2015 10:48 AM

All replies

  • Hi DSanchen,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 6, 2015 5:54 AM
  • Hi Amy,

    is there some progress with this issue ?

    In the meantime, I programmed a workaround that adds multiple non-standard UdpAnnouncementEndpoints (with a specific Uri, see below) to the DiscoveryBehavior object.

    For each network, that is working at the time of the DiscoveryBehavior creation, I "manually" determine the Broadcast address and compose the necessary SOAP-Uri (as defined in the WS-Discovery standard). For each Broadcast Uri I add the UdpAnnouncementEndpoint(Uri) with that Broadcast-Uri filled in.

    With these "manual" Announcement endpoints at the DiscoveryBehavior, all seems to work as intended...

    Best regards,


    Wednesday, April 1, 2015 8:56 AM
  • I am also seeing this problem and would be interested in any feedback.  Should this be submitted as an issue somewhere?

    I am considering either adding a re-try loop around the creation of the ServiceHost, or just not supporting Announcement at all.

    Monday, July 27, 2015 7:37 PM