[UWP] Windows Networking VPN API, timeout for vpnClient background task + behavior

Tyler Fonzi 26 Reputation points
2022-02-18T15:29:22.877+00:00

I am implementing a system that uses a vpnClient type background task for use with the Windows Networking VPN API. I've been encountering some weird behavior where it seems like connecting the VPN profile via ConnectProfileAsync, which then in turn triggers my background task, times out after 15 seconds (I am expecting the connection to take around 30 seconds). In this case, it times out and ConnectProfileAsync returns an error of type "Other". In practice, it seems like I can just call the ConnectProfileAsync function again right after failure, and it will pick back right up where it started, eventually leading to a successfully connected profile?? This makes no sense to me. Questions:

  1. Does anyone have insight into how these background tasks work that would explain the "pick up where it left off" behavior?
  2. My main issue is the timeout, is there a way to increase this timeout for ConnectProfileAsync? I tried the extendedBackgroundTaskTime restricted capability but that didn't seem to affect anything.

If anyone has any knowledge to share pertaining this, it would be greatly appreciated.

Universal Windows Platform (UWP)
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,420 questions
Windows 10 Network
Windows 10 Network
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Network: A group of devices that communicate either wirelessly or via a physical connection.
2,271 questions
0 comments No comments
{count} votes

Accepted answer
  1. Peter Smith 581 Reputation points Microsoft Employee
    2022-02-21T19:47:22.44+00:00

    The IVpnPlug Connect call is normally given more than 15 seconds before it times out. Have you looked at the VPN sample on Github?


1 additional answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,851 Reputation points
    2022-02-21T05:03:41.263+00:00

    Hello, Welcome to Microsoft Q&A,

    Your issue that might be related to VPN and currently there is official code sample that you could refer to.

    Thanks
    Nico Zhu

    0 comments No comments