none
How to Get Faulted exception on connection lost RRS feed

  • Question

  • HI,

    I have 3 systems connected to a switch (its local network). I have a wcf service hosted as Windows service in one pc.

    From other pc's i have client running which connects to service (I have created Channel using DupleChannelFactory).

    And registered for faulted exception by typecasting the proxy to ICommunicationObject. This works fine.

    When i unplug the n/w cable of the system where service is running,

    - Am not receiving faulted exception at client's side.

    - Even after connecting the n/w cable back, not able to contact service.

    Any way to get faulted exceptions in the above scenarios.

    Regards

    Hiran R


    Please mark the post as answer if it is helpfull to you - Hiran Repakula

    Monday, July 21, 2014 11:10 AM

All replies

  • You should get a CommunicationException - http://msdn.microsoft.com/en-us/library/system.servicemodel.communicationexception(v=vs.110).aspx when you are trying to make a request from your client.

    Based on this exceptino you should test the state of your proxy to see if you can reuse it or not. But with a network loss you'll have to instanciate your proxy again. Maybe you should implement a retry mechanism to figure out when the network connectivity is back.

    Monday, July 21, 2014 11:27 AM
  • Hi,

    My Application is mainly used to show whats happening in service. So once client (UI) is launched it registers with callback obj, and starts getting updates. If due some reasons (e.g. n/w is unplugged) connection is lost, i need to get faulted exception. Other wise the client might not show the updates from service(as it will not receive any) and it may give a feeling to user that the application has hung.

    So my main concern is that UI(client) should notify the user that it is disconnected from service and trying to reconnect. I have done the reconnect mechanism but i need to know (faulted exception) when i have to reconnect.

    Mean while, even after communication exception the proxy state is still open.

    Any other mechanisms how i can identify the scenario.

    Regards

    Hiran R


    Please mark the post as answer if it is helpfull to you - Hiran Repakula

    Monday, July 21, 2014 6:31 PM