locked
Intermittent XMLHttpRequest: Network Error 0x2f7d, Could not complete the operation due to error 00002f7d.

    Question

  • I get intermittent errors when trying to make XHR requests from inside the ready function of a pageControl inside a WinJS Metro Store App.

    It will work on average 8 times out of 10 but every now and then i get the following error:

    XMLHttpRequest: Network Error 0x2f7d, Could not complete the operation due to error 00002f7d.

    None of the events associated with the XHAR requests get called (error, success, complete) additionally if I click on the error in the JavascriptConsole it takes me to a line in an HTML file, the exact line number changes but often ends up being a blank line or the first line of the file.

    It seems to only fail when I do SSL requests

    Any help would be appreciated, this is blocking us from submitting to the app store.


    Thursday, October 04, 2012 2:47 PM

Answers

  • Unfortunately I am not able to reproduce the issue you are running into. I even ran with 300 requests and still get no error. It looks very much like an environmental issue on your side. If you can zip up and share your entire repro project at some location (SkyDrive?) maybe I can try to repro with your complete project.

    Here is the code I am using for your reference. I removed the jQuery stuff and used WinJS.xhr directly.

    app.onactivated = function (args) {

        ....
        args.setPromise(WinJS.UI.processAll().done(onLoad));
    }

    function onLoad() {
            var btnUseXHR = document.getElementById("btnUseXHR");
            btnUseXHR.addEventListener("click", SendHTTPRequests, false);
        }
        function SendHTTPRequests() {
            var txtOut = document.getElementById("txtOut");
            txtOut.value = "";
            for (var i = 0; i < 300; i++) {
                WinJS.xhr({
                    url: 'https://www.google.com',
                }).done(onCompleted, onError);
            }       
        }
        function onCompleted(request) {
            var txtOut = document.getElementById("txtOut");
            var strOut = txtOut.value;
            strOut += "request completed with status: " + request.status + "\r\n";
            txtOut.value = strOut;
        }
        function onError(request) {
            var txtOut = document.getElementById("txtOut");
            var strOut = txtOut.value;
            strOut += "request had an error\r\n";
            txtOut.value = strOut;
        }

    Monday, October 15, 2012 9:46 PM
    Moderator

All replies

  • Hello Stephen,

    The error you are getting is a WinINet error code 0x2f7D = 0n12157:

    C:\>err 2f7d
    # for hex 0x2f7d / decimal 12157
      ERROR_INTERNET_SECURITY_CHANNEL_ERROR                          inetmsg.h
      ERROR_WINHTTP_SECURE_CHANNEL_ERROR                             winhttp.h
      ERROR_INTERNET_SECURITY_CHANNEL_ERROR                          wininet.h
    # 3 matches found for "2f7d"

    This error can happen due to several reasons. Since it is happening intermittently, I would recommend checking the server certificate of the target website and find out if it has any errors in the certificate chain. To check it very easily, you could simply use IE to browse to the https://... site and check if you get any certificate errors. An alternative to troubleshooting the issue is to enable CAPI2 logging as mentioned here: http://technet.microsoft.com/en-us/library/cc749296(v=WS.10).aspx and see if you get any type of Cryptography errors. You can also enable schannel logging to find out if you are getting schannel errors: http://support.microsoft.com/kb/260729.

    If it still doesn't help and if the URL is external, can you share the URL so that I can try to reproduce the same issue?

    Thanks,

    Prashant.

    Friday, October 05, 2012 11:35 PM
    Moderator
  • Hi,

    I managed to reproduce the error in a standalone environment.  It seems to be concurrent xhr requests to any https site.  I can do async http calls or non async https calls but not concurrent async https calls.  In these examples I used jQuery as it doesn't crash the app completely.  The same happens with WinJS.xhr except that the app stops the first time it encounters the error.

    This works:

    for (var i = 0; i < 200; i++) {
        $.ajax({
            url: 'https://www.google.com',
            async: false,
            error: function(data) {
                console.log("error");
            },
            success: function(data) {
                console.log("success");
            }
        });
    }

    But this fails:

    for (var i = 0; i < 200; i++) {
        $.ajax({
            url: 'https://www.google.com',
            async: true, //<--Changed this
            error: function(data) {
                console.log("error");
            },
            success: function(data) {
                console.log("success");
            }
        });
    }

    Friday, October 12, 2012 9:46 AM
  • Unfortunately I am not able to reproduce the issue you are running into. I even ran with 300 requests and still get no error. It looks very much like an environmental issue on your side. If you can zip up and share your entire repro project at some location (SkyDrive?) maybe I can try to repro with your complete project.

    Here is the code I am using for your reference. I removed the jQuery stuff and used WinJS.xhr directly.

    app.onactivated = function (args) {

        ....
        args.setPromise(WinJS.UI.processAll().done(onLoad));
    }

    function onLoad() {
            var btnUseXHR = document.getElementById("btnUseXHR");
            btnUseXHR.addEventListener("click", SendHTTPRequests, false);
        }
        function SendHTTPRequests() {
            var txtOut = document.getElementById("txtOut");
            txtOut.value = "";
            for (var i = 0; i < 300; i++) {
                WinJS.xhr({
                    url: 'https://www.google.com',
                }).done(onCompleted, onError);
            }       
        }
        function onCompleted(request) {
            var txtOut = document.getElementById("txtOut");
            var strOut = txtOut.value;
            strOut += "request completed with status: " + request.status + "\r\n";
            txtOut.value = strOut;
        }
        function onError(request) {
            var txtOut = document.getElementById("txtOut");
            var strOut = txtOut.value;
            strOut += "request had an error\r\n";
            txtOut.value = strOut;
        }

    Monday, October 15, 2012 9:46 PM
    Moderator