Solved

Ping (IsAlive) between two WCF windows Services

Posted on 2013-01-02
5
1,466 Views
Last Modified: 2013-01-16
Hi Experts,

I am looking to communicate between two Services (rather two instances of the same service) on two different servers. InstanceB should periodically check if InstanceA is alive.

These services are producing services and not consuming services. Both instances would be running at the same time, but only InstanceA would be producing the needed values. Only if InstanceA fails, would InstanceB takeover.

I'm thinking of taking the 'IsAlive' approach where InstanceB checks if InstanceA is alive every 10 seconds. I've added an IsAlive() method to my contract.  Since both the Instances would be Identical, how would my code to call the IsAlive() method or config file have to change?

I would appreciate a code sample.

Thanks in advance!
0
Comment
Question by:InquisitiveMind
5 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38739709
this post answers your question:
http://stackoverflow.com/questions/2867486/is-there-an-example-of-checking-on-if-a-wcf-service-is-online

basically, it says that you don;t need ping or IsAlive or anything special to detect if service is available.
simple use exception handling to catch timeout exception (or any combination of similar exceptions) and proceed according to your requirement (switch to the backup service).
0
 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 38739728
To just check availability/IsActive you can add a timmer in the both Services or only backup services. But it will be worth to ready following as it seems you are interested in failover/mirror services.

http://www.codeguru.com/csharp/.net/net_wcf/article.php/c19895/Introduction-to-Routing-Service-in-WCF-40.htm

and

http://stackoverflow.com/questions/3824881/design-pattern-for-wcf-client-switching-and-failover-capabilities

Thanks
0
 
LVL 25

Expert Comment

by:apeter
ID: 38741904
Is it like client will call InstanceB....and instaneB will check if instanceA is alive then it will ask InstanceA to perform and work instaed of InstanceB doing the same work ?
0
 

Author Comment

by:InquisitiveMind
ID: 38741931
@apeter:

InstanceA and InstanceB are both producing services(both auto start) and not consuming services (When I say producing services, they have a method called GenerateValues() which are generated every 15 seconds. )

Both of them are in a running state initially, but only InstanceA has the GenerateValues() method returning values to the client upon OnStart. InstanceB will not be returning the values. It should start generate values method only when a ping to InstanceA doesn't return a value. Is that any better?
0
 
LVL 25

Expert Comment

by:apeter
ID: 38742010
then below might work ?
         if (InstanceAProxy.IsAlive())
                       InstanceAProxy.GenerateValues()
          else  if  (InstanceBProxy.IsAlive())
                       InstanceBProxy.GenerateValues()
          else
                  //what happens

But why InstanceA is not always live ?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question