Forum Discussion

TonyJoy's avatar
TonyJoy
Copper Contributor
Feb 29, 2024

OneDrive: Operation timed out after 60011 milliseconds with 92 out of 92 bytes received

Hello dev team, Tony here from WPvivid.com. We have integrated OneDrive in our app. Recently we've got an issue: We use "https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession?view=odsp-graph-online" for uploading file exceeds 4MB to OneDrive. The main code our app uses for creating a upload session is as follows: $path=$remote_path.'/'.basename($file); $url='https://graph.microsoft.com/v1.0/me/drive/root:/'.$path.':/createUploadSession'; $response=$this->remote_post($url); Obtained uploadUrl $response['body']['uploadUrl'], and then after getting the uploadUrl   $response['body']['uploadUrl', it uses this url to upload files in chunks. The main code is as follows: $curl = curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt($curl, CURLOPT_TIMEOUT, 60); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $upload_size=min($upload_size,$file_size-$uploaded); if ($uploaded) fseek($file_handle, $uploaded); $headers = array( "Content-Length: $upload_size", "Content-Range: bytes $uploaded-$upload_end/".$file_size, ); $headers[] = 'Authorization: Bearer ' . $this->options['token']['access_token']; $options = array( CURLOPT_URL => $url, CURLOPT_HTTPHEADER => $headers, CURLOPT_PUT => true, CURLOPT_INFILE => $file_handle, CURLOPT_INFILESIZE => $upload_size, CURLOPT_RETURNTRANSFER=>true, ); curl_setopt_array($curl, $options); $response=curl_exec($curl); $http_code = curl_getinfo($curl,CURLINFO_HTTP_CODE); Starting around February 13th, some users had this problem on their sites: $response=curl_exec($curl); There is no response when the process is executed here, and the process is stuck because the curl timeout is set for 60 seconds. After 60 seconds, the task is terminated, the value of $response is false, and the $http_code obtained by curl_getinfo is 202. We have also implemented breakpoint resume uploading, so when $response=curl_exec($curl) did not respond, our app will retry 3 times and continued uploading using breakpoint resume. However, the problem now is there is no response for http request. For example, the chunk size is 2MB. After there is no response, the next upload is 4MB but there is still no response. Then our app will retry again to upload 6MB but still get no response. In the end, the file upload fails with the curl_error($curl ); "Operation timed out after 60011 milliseconds with 92 out of 92 bytes received" Please help. Thank you!

No RepliesBe the first to reply

Resources