Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

WinHttpSendRequest handle leak

WinHttpSendRequest handle leak

WinHttpSendRequest handle leak

I have a WinHttp application that repeatedly sends requests via WinHttpSendRequest. When running this app on a Win10 system, the open handle count after the WinHttpSendRequest call will rise to a particular value (around 370) then stay at that value.

On a Win Server 2016 system, this call results in an increasing number of open handles that continues until I start getting network errors. At that time the open handle count will be around 65,700.

I assume the handle count is due to some pool that WinHttp is managing, probably related to HTTP connections? Why would this count continue to increase on one system and not another ... is there some registry setting that controls this?

Thanks in advance.

RE: WinHttpSendRequest handle leak

The documentation does tell you to delete the handle when a response is received.

Quote (https://docs.microsoft.com/en-us/windows/win32/api...)

An application must not delete or alter the buffer pointed to by lpOptional until the request handle is closed or the call to WinHttpReceiveResponse has completed, because an authentication challenge or redirect that required the optional data could be encountered in the course of receiving the response. If the operation must be aborted with WinHttpCloseHandle, the application must keep the buffer valid until it receives the callback WINHTTP_CALLBACK_STATUS_REQUEST_ERROR with an ERROR_WINHTTP_OPERATION_CANCELLED error code.
Are you waiting for a response or just blindly sending. Could it be that on W10 you are getting responses and therefore deleting the handles but on the server you are not getting responses and not deleting.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close