'For what reason might the camera return the error "Invalid session in request data!"?

The problem is that the error occurs intermittently I have a Dahua HDW2230TP-AS-0280B camera. I back up the video to my server every 10 minutes. The request looks like this:

<?php 
function reqCam($url)
{
    $ch = curl_init($url);
    curl_setopt_array($ch, [CURLOPT_USERPWD => "admin:password", CURLOPT_CONNECTTIMEOUT => 2, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HTTPAUTH => CURLAUTH_ANY]);
    return curl_exec($ch);
}

# step 1. curl request to create a task (id)
$task = reqCam("$urlcam/cgi-bin/mediaFileFind.cgi?action=factory.create");
$id = explode("=",trim($task))[1]; // trim ID
# Step 2. set $start and $end to search for the video
reqCam("$urlcam/cgi-bin/mediaFileFind.cgi?action=findFile&object=$id&condition.Channel=1&condition.StartTime=$start&condition.EndTime=$end&condition.Types[0]=dav");
# step 3. displaying the video list
$listvideo = reqCam("$urlcam/cgi-bin/mediaFileFind.cgi?action=findNextFile&object=$id&count=100");

And this code can show about 10 (sometimes more) errors of this kind for 100 iterations:

{"error":{"code":287637505, "message": "Invalid session in request data!"}, "result":false}

the error occurs in the second step, when I set the search parameters. There is no pattern that I can detect.

How to solve this problem?



Solution 1:[1]

The admin panel of the camera said that I was using the latest version of the firmware, but a new version was published on the official website. I installed it and the errors are much less. About 90%

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 accountnujen