locked
Check for VPN Connection Exists RRS feed

  • Question

  • Hello

    I am working on a windows store app for Enterprise. This app will require internet and VPN connection to get data. I have found a way to check for internet access. However, I am not sure how to check if there is a VPN tunnel available. If VPN is available then I can make a call to a WebService and get data. If there is no VPN then the WebService call will fail [after about 10-15 seconds]. I can assume that if the WebService calls fails that means there is no VPN but there must be another way to find this out before even calling a Service.

    Please help.
    Thanks

    Bevan

    Thursday, December 5, 2013 8:59 PM

Answers

  • Hi Bevan,

    Sorry, I don't think we can detect VPN connection in Windows Store App, currently there is no API for you. As you told, try the connection might be the only solution.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Bevan Dias Monday, December 9, 2013 3:47 PM
    Friday, December 6, 2013 9:28 AM
    Moderator

All replies

  • Hi Bevan,

    Sorry, I don't think we can detect VPN connection in Windows Store App, currently there is no API for you. As you told, try the connection might be the only solution.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Bevan Dias Monday, December 9, 2013 3:47 PM
    Friday, December 6, 2013 9:28 AM
    Moderator
  • Thank you James!

    I have added a timeout to my http call, if the call does not return in 3 seconds for example, I assume that there is no VPN so the service cannot be reached. If there is VPN then the service call returns immediately.

    Cheers

    Bevan

    Monday, December 9, 2013 3:47 PM
  • We're using Microsoft Direct Access rather than a VPN but I think this is worth sharing anyway.
    Rather than calling a web service I'm just using the HttpClient's GetAsync() method to call a small file hosted on an internally hosted web server. This minimises the payload as much as possible which may be important if your users are connected using devices with 3G/4G with data limit.
    I'm wrapping the call in a Stopwatch to get a rough idea of the round robin request/response and visualising that for the users so they know how good their connection to the corporate network is. This info is far more useful than the WiFi/Mobile signal bars.

    Stopwatch stopWatch = new Stopwatch();
    stopWatch.Start();
    HttpClient httpClient = new HttpClient();
    HttpResponseMessage response = await httpClient.GetAsync(nslUri);
    response.EnsureSuccessStatusCode(); // -- throw exception if not a success code
    stopWatch.Stop();
    TimeSpan ts = stopWatch.Elapsed;


    This might also be of interest...

    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.networking.vpn.aspx



    • Edited by RD8388 Monday, April 20, 2015 1:09 PM
    Monday, April 20, 2015 1:08 PM