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