0

I have followed this Microsoft article for installing WCF service as windows service (with netTCPbinding).

Following is the code for setting up the Announcement from the service side:

protected override void OnStart(string[] args)
{
  if (myServiceHost != null)
  {
    myServiceHost.Close();
  }
  myServiceHost = new ServiceHost(typeof(MonitoringService));

  ServiceDiscoveryBehavior serviceDiscoveryBehavior = new ServiceDiscoveryBehavior();
  serviceDiscoveryBehavior.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint());

  myServiceHost.Description.Behaviors.Add(serviceDiscoveryBehavior);
  myServiceHost.Description.Endpoints.Add(new UdpDiscoveryEndpoint());

  myServiceHost.Open();
}

The problem I am facing is, once the service becomes available (say after restart), it will notify the client that it's back but that notification is going to client two times and hence it is trying to perform some cleanup two times.

Following is the detail of the service, where it is running. (2772 is the PID of the service).

Service d

What I am suspecting is this service (for some reason) is listening "two times" on the same port (I don't know how this is possible) as we can see in two TCP rows, the status is listening. This might be the reason I am thinking that is causing the Online event triggered on the client side two times once the service comes online.

Please provide your inputs. I have followed the same steps for installation as mentioned in the above link.

EDIT

Why is this service shown two times, even for the same port?

Cœur
  • 37,241
  • 25
  • 195
  • 267
OldSchool
  • 2,123
  • 4
  • 23
  • 45
  • Your WCF service is listening to two different addresses IPV4 and IPV6 The answer to the following stack overflow question looks like it might resolve your issue. https://stackoverflow.com/questions/2028879/ipv4-remote-address-in-wcf – Stuart Smith Dec 20 '17 at 19:02
  • @StuartSmith, yes it's IPV4 and IPV6 but why it's triggering the online service event handler at client side twice? What is the connection? – OldSchool Dec 20 '17 at 19:07
  • @StuartSmith At one point of time it should be using one 4 or 6. – OldSchool Dec 20 '17 at 19:08

0 Answers0