XMLHttpRequest() Used to work, now fails!

I am using XMLHttpRequest to upload recorded WebRTC videos. This used to work but I have not used it in awhile. I am not sure what I may have done to create this error as it has been quite awhile since I have used it. Now I am getting this error in the console:

Here is the javascript I am using:

document.getElementById('btn-stop-recording').onclick = function() {

        document.getElementById('btn-start-recording').disabled = true;
        document.getElementById('btn-stop-recording').disabled = true;
        //document.getElementById('video-preview').srcObject = stream;

        var streamid = event.streamid;
        recorder[streamid].stopRecording(function() {

        var blob = recorder[streamid].getBlob();

                var fileObject = new File([blob], fileName, {
                            type: 'video/webm'
                        });

var fileType = 'video'; // or "audio"
var fileName = getFileName('webm');

var formData = new FormData();
formData.append(fileType + '-filename', fileName);
formData.append(fileType + '-blob', blob);

xhr('save.php', formData, function (fName) {
//    window.open(location.href + fName);
});

function xhr(url, data, callback) {
    var request = new XMLHttpRequest();
    request.onreadystatechange = function () {
        if (request.readyState == 4 && request.status == 200) {
            callback(location.href + request.responseText);
        }
    };
    request.open('POST', url, true);
        console.log(" POST url = ", url);
    request.send(data);
}

Please note that I am not a seasoned programmer and green as can be. The above script was created by another person and I modified it to fit my needs. Remember it worked fine at one point.

One other note, the server is running behind Haproxy. Here is it’s log:
Apr 11 16:10:11 localhost haproxy[299]: xx.xx.106.57:4604 [11/Apr/2022:16:10:11.361] http_lb~ bcast2/broadcast1 0/0/1/1/222 500 816 - - ---- 6/6/0/1/0 0/0 “POST /save.php HTTP/1.1”

I’ve obfuscated a couple things to avoid any traffic on my site.
I just need someone to suggest trouble shooting techniques.

Thanks in advance,

Ray

Maybe a stupid question but did you try restarting the server? It sounds like a server issue and not necessarily something to do with the client code (especially considering you didn’t change anything).

I don’t have an answer for you, it’s very hard to know much of anything based on the information we have. Maybe look in the network tab in the browser as well to see if it can give you some more information. The 500 status code is a generic “catch-all” response.

Here is the network information:

Solved. Somehow I introduced a bug in my Haproxy config.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.