Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Error 12029 WinHTTP

Error 12029 WinHTTP

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresjsonhelplearning
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Diprom
    wrote on last edited by
    #1

    Hello. I am applying a demo project in which I use winhttp asynchronously via callback.
    After cyclic sending of n-requests, error 12029 is often generated. If you insert Sleep in the code, then
    all words go away without errors. I would like to understand how you can without sleep. Made specifically so that later
    tie the call to the queue.

    #include "stdafx.h"
    #include
    #include
    #include
    #pragma comment(lib,"winhttp")

    // Context value structure.
    typedef struct {
    HINTERNET hSession; // HTTP Session
    HINTERNET hConnect; // Connection handle
    HINTERNET hRequest; // Resource request handle
    DWORD dwSize; // Size of the latest data block
    DWORD dwTotalSize; // Size of the total data
    LPSTR lpBuffer; // Buffer for storing read data
    char* SendBuffer; // Send buffer
    wchar_t* URL; // URL
    int Resend; // flag to resend
    DWORD SendTimeout; // send timeout
    DWORD ReceiveTimeout; // receive timeout
    DWORD ConnectTimeout; // connect timeout
    DWORD ResolveTimeout; // resolve timeout
    bool IsBadRequest; // bad request complete
    WINHTTP_STATUS_CALLBACK pCallback; //callback

    } REQUEST_CONTEXT;

    int CounterGood = 0;
    int CounterBad = 0;

    // This macro returns the constant name in a string.
    #define CASE_OF(constant) case constant: return (L# constant)

    LPCWSTR GetApiErrorString(DWORD dwResult)
    {
    // Return the error result as a string so that the
    // name of the function causing the error can be displayed.
    switch(dwResult)
    {
    CASE_OF( API_RECEIVE_RESPONSE );
    CASE_OF( API_QUERY_DATA_AVAILABLE );
    CASE_OF( API_READ_DATA );
    CASE_OF( API_WRITE_DATA );
    CASE_OF( API_SEND_REQUEST );
    }
    return L"Unknown function";
    }

    void Cleanup (REQUEST_CONTEXT *cpContext)
    {

    if (!cpContext)
    {
        return;
    }
    if (cpContext->IsBadRequest)
        CounterBad++;
    else
        CounterGood++;
    WCHAR szBuffer\[256\];
    // Set the memo to indicate a closed handle.
    swprintf(szBuffer,sizeof(szBuffer), L"Cleanup");
    //printf("%ws",szBuffer);
    if (cpContext->hRequest)
    {
        swprintf(szBuffer, sizeof(szBuffer), L">WinHttpSetStatusCallback
    
    L V 3 Replies Last reply
    0
    • D Diprom

      Hello. I am applying a demo project in which I use winhttp asynchronously via callback.
      After cyclic sending of n-requests, error 12029 is often generated. If you insert Sleep in the code, then
      all words go away without errors. I would like to understand how you can without sleep. Made specifically so that later
      tie the call to the queue.

      #include "stdafx.h"
      #include
      #include
      #include
      #pragma comment(lib,"winhttp")

      // Context value structure.
      typedef struct {
      HINTERNET hSession; // HTTP Session
      HINTERNET hConnect; // Connection handle
      HINTERNET hRequest; // Resource request handle
      DWORD dwSize; // Size of the latest data block
      DWORD dwTotalSize; // Size of the total data
      LPSTR lpBuffer; // Buffer for storing read data
      char* SendBuffer; // Send buffer
      wchar_t* URL; // URL
      int Resend; // flag to resend
      DWORD SendTimeout; // send timeout
      DWORD ReceiveTimeout; // receive timeout
      DWORD ConnectTimeout; // connect timeout
      DWORD ResolveTimeout; // resolve timeout
      bool IsBadRequest; // bad request complete
      WINHTTP_STATUS_CALLBACK pCallback; //callback

      } REQUEST_CONTEXT;

      int CounterGood = 0;
      int CounterBad = 0;

      // This macro returns the constant name in a string.
      #define CASE_OF(constant) case constant: return (L# constant)

      LPCWSTR GetApiErrorString(DWORD dwResult)
      {
      // Return the error result as a string so that the
      // name of the function causing the error can be displayed.
      switch(dwResult)
      {
      CASE_OF( API_RECEIVE_RESPONSE );
      CASE_OF( API_QUERY_DATA_AVAILABLE );
      CASE_OF( API_READ_DATA );
      CASE_OF( API_WRITE_DATA );
      CASE_OF( API_SEND_REQUEST );
      }
      return L"Unknown function";
      }

      void Cleanup (REQUEST_CONTEXT *cpContext)
      {

      if (!cpContext)
      {
          return;
      }
      if (cpContext->IsBadRequest)
          CounterBad++;
      else
          CounterGood++;
      WCHAR szBuffer\[256\];
      // Set the memo to indicate a closed handle.
      swprintf(szBuffer,sizeof(szBuffer), L"Cleanup");
      //printf("%ws",szBuffer);
      if (cpContext->hRequest)
      {
          swprintf(szBuffer, sizeof(szBuffer), L">WinHttpSetStatusCallback
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You cannot expect anyone to plough through those 900 or so lines of code on your behalf. Please remove all the code not related to your problem and explain what the problem is, in proper detail.

      1 Reply Last reply
      0
      • D Diprom

        Hello. I am applying a demo project in which I use winhttp asynchronously via callback.
        After cyclic sending of n-requests, error 12029 is often generated. If you insert Sleep in the code, then
        all words go away without errors. I would like to understand how you can without sleep. Made specifically so that later
        tie the call to the queue.

        #include "stdafx.h"
        #include
        #include
        #include
        #pragma comment(lib,"winhttp")

        // Context value structure.
        typedef struct {
        HINTERNET hSession; // HTTP Session
        HINTERNET hConnect; // Connection handle
        HINTERNET hRequest; // Resource request handle
        DWORD dwSize; // Size of the latest data block
        DWORD dwTotalSize; // Size of the total data
        LPSTR lpBuffer; // Buffer for storing read data
        char* SendBuffer; // Send buffer
        wchar_t* URL; // URL
        int Resend; // flag to resend
        DWORD SendTimeout; // send timeout
        DWORD ReceiveTimeout; // receive timeout
        DWORD ConnectTimeout; // connect timeout
        DWORD ResolveTimeout; // resolve timeout
        bool IsBadRequest; // bad request complete
        WINHTTP_STATUS_CALLBACK pCallback; //callback

        } REQUEST_CONTEXT;

        int CounterGood = 0;
        int CounterBad = 0;

        // This macro returns the constant name in a string.
        #define CASE_OF(constant) case constant: return (L# constant)

        LPCWSTR GetApiErrorString(DWORD dwResult)
        {
        // Return the error result as a string so that the
        // name of the function causing the error can be displayed.
        switch(dwResult)
        {
        CASE_OF( API_RECEIVE_RESPONSE );
        CASE_OF( API_QUERY_DATA_AVAILABLE );
        CASE_OF( API_READ_DATA );
        CASE_OF( API_WRITE_DATA );
        CASE_OF( API_SEND_REQUEST );
        }
        return L"Unknown function";
        }

        void Cleanup (REQUEST_CONTEXT *cpContext)
        {

        if (!cpContext)
        {
            return;
        }
        if (cpContext->IsBadRequest)
            CounterBad++;
        else
            CounterGood++;
        WCHAR szBuffer\[256\];
        // Set the memo to indicate a closed handle.
        swprintf(szBuffer,sizeof(szBuffer), L"Cleanup");
        //printf("%ws",szBuffer);
        if (cpContext->hRequest)
        {
            swprintf(szBuffer, sizeof(szBuffer), L">WinHttpSetStatusCallback
        
        V Offline
        V Offline
        Victor Nijegorodov
        wrote on last edited by
        #3

        Diprom wrote:

        After cyclic sending of n-requests, error 12029 is often generated.

        What API call causes this error?

        D 1 Reply Last reply
        0
        • V Victor Nijegorodov

          Diprom wrote:

          After cyclic sending of n-requests, error 12029 is often generated.

          What API call causes this error?

          D Offline
          D Offline
          Diprom
          wrote on last edited by
          #4

          SendRequest(rcContext);
          Although this call always terminates normally. 12029 I catch in the callback AsyncCallback

          V 1 Reply Last reply
          0
          • D Diprom

            SendRequest(rcContext);
            Although this call always terminates normally. 12029 I catch in the callback AsyncCallback

            V Offline
            V Offline
            Victor Nijegorodov
            wrote on last edited by
            #5

            SendRequest looks like your own function. It calls a lot of WinHTTP functions. So which one of these WinHTTP functions fails with this error?

            1 Reply Last reply
            0
            • D Diprom

              Hello. I am applying a demo project in which I use winhttp asynchronously via callback.
              After cyclic sending of n-requests, error 12029 is often generated. If you insert Sleep in the code, then
              all words go away without errors. I would like to understand how you can without sleep. Made specifically so that later
              tie the call to the queue.

              #include "stdafx.h"
              #include
              #include
              #include
              #pragma comment(lib,"winhttp")

              // Context value structure.
              typedef struct {
              HINTERNET hSession; // HTTP Session
              HINTERNET hConnect; // Connection handle
              HINTERNET hRequest; // Resource request handle
              DWORD dwSize; // Size of the latest data block
              DWORD dwTotalSize; // Size of the total data
              LPSTR lpBuffer; // Buffer for storing read data
              char* SendBuffer; // Send buffer
              wchar_t* URL; // URL
              int Resend; // flag to resend
              DWORD SendTimeout; // send timeout
              DWORD ReceiveTimeout; // receive timeout
              DWORD ConnectTimeout; // connect timeout
              DWORD ResolveTimeout; // resolve timeout
              bool IsBadRequest; // bad request complete
              WINHTTP_STATUS_CALLBACK pCallback; //callback

              } REQUEST_CONTEXT;

              int CounterGood = 0;
              int CounterBad = 0;

              // This macro returns the constant name in a string.
              #define CASE_OF(constant) case constant: return (L# constant)

              LPCWSTR GetApiErrorString(DWORD dwResult)
              {
              // Return the error result as a string so that the
              // name of the function causing the error can be displayed.
              switch(dwResult)
              {
              CASE_OF( API_RECEIVE_RESPONSE );
              CASE_OF( API_QUERY_DATA_AVAILABLE );
              CASE_OF( API_READ_DATA );
              CASE_OF( API_WRITE_DATA );
              CASE_OF( API_SEND_REQUEST );
              }
              return L"Unknown function";
              }

              void Cleanup (REQUEST_CONTEXT *cpContext)
              {

              if (!cpContext)
              {
                  return;
              }
              if (cpContext->IsBadRequest)
                  CounterBad++;
              else
                  CounterGood++;
              WCHAR szBuffer\[256\];
              // Set the memo to indicate a closed handle.
              swprintf(szBuffer,sizeof(szBuffer), L"Cleanup");
              //printf("%ws",szBuffer);
              if (cpContext->hRequest)
              {
                  swprintf(szBuffer, sizeof(szBuffer), L">WinHttpSetStatusCallback
              
              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Hi,

              Diprom wrote:

              After cyclic sending of n-requests, error 12029 is often generated.

              The Windows operating system limits the number of half-open TCP connections. On the Windows 10 operating system you will be limited to 20 and on the older operating systems it could be as low as 10.

              Diprom wrote:

              for (int i = 0; i < 2000; i++)

              That's alot of asynchronous connections... the Windows operating system will not allow you to make 2000 outgoing connections this fast. Best Wishes, -David Delaune

              ScientiƦ de conservata veritate.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups