When does HttpClient.sendRequestAsync throw "The handle is in the wrong state for the requested operation"? RRS feed

  • Question

  • Occasionally I do get the following error output

    0x80072ef3 - JavaScript runtime error: The text associated with this error code could not be found.

    The handle is in the wrong state for the requested operation
    WinRT information: The handle is in the wrong state for the requested operation

    What does it mean?

    Thursday, December 18, 2014 7:38 AM


  • Probably more than one explanation for this, but the documentation here explains at least one:


    Even when WinHTTP is used in asynchronous mode, that is, when WINHTTP_FLAG_ASYNC has been set in WinHttpOpen, this function can operate either synchronously or asynchronously.  In either case, if the request is sent successfully, the application is called back with the completion status set to WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE. The WINHTTP_CALLBACK_STATUS_REQUEST_ERROR completion indicates that the operation completed asynchronously, but failed.  Upon receiving the WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE status callback, the application can start to receive a response from the server with WinHttpReceiveResponse. Before then, no other asynchronous functions can be called, otherwise, ERROR_WINHTTP_INCORRECT_HANDLE_STATE is returned.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, December 18, 2014 2:48 PM