none
ExchangeConnectionMode not reliable RRS feed

  • Question

  • I have an Add-In that enables / disables custom controls depending on whether or not there is a connection to the Primary Exchange Server.

    The problem that I'm having is that it takes a very long time for the value of ExchangeConnectionMode to update.   I've literally unplugged the network cable and checked the value in a for loop as a test and found that it could take anywhere from a few short seconds (4 or 5) to as long as 15-20 seconds.

    Perhaps I should use a Ping service?  Any ideas?

    Note:  We used Outlook in Cached mode

    SOFTWARE INFORMATION
    Outlook 2013 (15.0.4763.1000) MSO (15.0.4753.1001) 32-Bit



    MACHINE INFORMATION
    OS Name Microsoft Windows 7 Enterprise N
    Version 6.1.7601 Service Pack 1 Build 7601
    System Type x64-based PC
    Processor Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz, 3601 Mhz, 4 Core(s), 8 Logical Processor(s)
    BIOS Version/Date Hewlett-Packard L52 v01.41, 4/13/2015


    • Edited by GermanEZI Thursday, March 31, 2016 5:37 PM Clarification
    Thursday, March 31, 2016 5:28 PM

Answers

  • Hello Edward,

    The "Dir" command was very interesting and something that I liked.  However, I could not control the time it took to return when the targeted server was unreachable.

    What I decided to do was abandon the thought of testing for network / server availability and go the route of exception handling in the case where an attempt to reach the Exchange Server failed.

    We needed timely and accurate information on the connected state of the server due to certain business processes that needed to be implemented, and I couldn't find one that really worked inside of an Add-In

    Further see Jason Wang's comments outline how trying to find a good solution for detecting connectivity is simply not full proof  in the article in this forum entitled "Alternative for NetworkChange"

    Here is an overview of the testing I performed.



    SUMMARY OF TESTING
    METHOD PROS CONS
    ExchangeConnectionMode Dynamic, and 0 network overhead. Sometimes takes too long to refresh status
    GetIsNetworkAvailable() API Easy to implement. This call basically tests the status of your NIC, and NOT if your network is available. The documentation is a little misleading.
    NetworkAvailabilityChanged event Easy to implement and the results are near instant Does not seem to work in a virtual environment such as "Virtual Box". Must run in main thread of application. Great if you're running a simply console app. I haven't seen any examples of this running in an Outlook Add-In
    NetworkAddressChanged event Same as above Same as above
    Ping You can target a specific server, and control the timeout You'll need to have a heart to heart conversation with your Admin about 900 users pinging one of his/her servers. They don't like that sort of thing :)






    • Marked as answer by GermanEZI Tuesday, April 5, 2016 7:09 PM
    • Edited by GermanEZI Tuesday, April 5, 2016 7:13 PM Table formatting
    Tuesday, April 5, 2016 6:47 PM

All replies

  • Hello German,

    You should check the network connection first. Then you can check the ExchangeConnectionMode  property value.

    Thursday, March 31, 2016 6:20 PM
  • Hello Eugene,

    By "check the network connection" do you mean do a Ping?
    Thursday, March 31, 2016 6:38 PM
  • Yes, it can be a ping. Or just try to open any web site like Google.
    Thursday, March 31, 2016 6:45 PM
  • Oh,  I see what you mean.

    I was using a Ping in my code, but sometimes a slow response (exceeding the timeout value), caused my code to return false for network availability.

    I've been pouring through threads on this, and there doesn't seem to be a reliable solution ...

    The event, System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged is not reliable because sometimes my code is used on Virtual networks (e.g. Virtual Box), and the event simply doesn't fire.

    I'll keep searching, and post if I find an answer.

    Thanks again.


    Thursday, March 31, 2016 6:51 PM
  • Hi GermanH,

    As you have used, you could use ExchangeConnectionMode to check connection mode, when will it take a long time? Do you mean it takes long time when there is no network? There is no better method in Outlook object model to check the connection status of network.

    After researching, I suggest you try to Dir on the shared drive to check whether it is faster.

    Option Explicit
    Sub TestForNetworkDrive()
    
    'suppose the file we want is at Z:\cool\vba\files\file.txt
    If Len(Dir("Z:\cool\vba\files\file.txt")) = 0 Then
        'handle network not available issue
        MsgBox ("Network share not found...")
    Else
        'do timer-based code here
        MsgBox ("Let's get to work!")
    End If
    
    End Sub
    

    For checking network, it is more related with VBA, I suggest you go to the forum below for help.

    Reference: https://social.msdn.microsoft.com/Forums/en-US/home?forum=isvvba

    Best Regards,

    Edward


    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, April 1, 2016 1:59 AM
  • German,

    You may find the NetworkAddressChanged event helpful. Handling these two events allows to recognize the connection state.

    Friday, April 1, 2016 8:03 AM
  • Hello Eugene,


    Yes, I went through that one quite a bit.  I couldn't get the event to fire.  It looked good.

    It works perfectly on my regular machine, but it does not fire in my VM environment.  I'm using Virtual Box.  It would seem that these events don't work in Virtual Environments;

    I've been searching for a solution to that, since there are a wide variety of networking configurations and I'm never sure what environment our users are running.
    Friday, April 1, 2016 5:58 PM
  • Hello Edward,

    If I were to unplug the network cable it would take some time before ExchangeConnectionMode would be set to one of the disconnected states.  If I were to reconnect the network cable I've seen it take up to 20 seconds (I tested this before writing this) for ExchangeConnectionMode is set to one of the connected states.

    The "Dir" solution is an interesting one I haven't thought of.  I'll look into it.

    Friday, April 1, 2016 8:00 PM
  • These two events working together should cover all possible scenarious.
    Saturday, April 2, 2016 8:40 AM
  • Hi GermanH,

    If you have any updates about this questions, please feel free to let us know.

    Best Regards,

    Edward


    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.


    Tuesday, April 5, 2016 1:06 AM
  • Hello Edward,

    The "Dir" command was very interesting and something that I liked.  However, I could not control the time it took to return when the targeted server was unreachable.

    What I decided to do was abandon the thought of testing for network / server availability and go the route of exception handling in the case where an attempt to reach the Exchange Server failed.

    We needed timely and accurate information on the connected state of the server due to certain business processes that needed to be implemented, and I couldn't find one that really worked inside of an Add-In

    Further see Jason Wang's comments outline how trying to find a good solution for detecting connectivity is simply not full proof  in the article in this forum entitled "Alternative for NetworkChange"

    Here is an overview of the testing I performed.



    SUMMARY OF TESTING
    METHOD PROS CONS
    ExchangeConnectionMode Dynamic, and 0 network overhead. Sometimes takes too long to refresh status
    GetIsNetworkAvailable() API Easy to implement. This call basically tests the status of your NIC, and NOT if your network is available. The documentation is a little misleading.
    NetworkAvailabilityChanged event Easy to implement and the results are near instant Does not seem to work in a virtual environment such as "Virtual Box". Must run in main thread of application. Great if you're running a simply console app. I haven't seen any examples of this running in an Outlook Add-In
    NetworkAddressChanged event Same as above Same as above
    Ping You can target a specific server, and control the timeout You'll need to have a heart to heart conversation with your Admin about 900 users pinging one of his/her servers. They don't like that sort of thing :)






    • Marked as answer by GermanEZI Tuesday, April 5, 2016 7:09 PM
    • Edited by GermanEZI Tuesday, April 5, 2016 7:13 PM Table formatting
    Tuesday, April 5, 2016 6:47 PM