FwpmFilterAdd occasionally fails with return code 31

Pankaj Mehta 0 Reputation points
2024-08-22T08:51:14.0133333+00:00

I am creating Ipsec tunnel using Windows Filtering Platform API in the process. Code is on the line of example provided at https://learn.microsoft.com/en-us/windows/win32/fwp/using-transport-mode

  • Code works 95% percent of the times
  • But for some random 5%, it fails with return code 31(ERROR_GEN_FAILURE) when API FwpmFilterAdd0 is called
  • General failure doesn't provide any useful info on what has happened or how I can make the code more robust.
  • My platform in Windows Server 2019
  • I have checked the System event logs and cannot find any useful trace there.

My questions is how to get better diagnostic information to debug this error? Any other tips would be useful.

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,707 questions
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,588 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.