Closed developerrajtomar closed 6 years ago
Hello @developerrajtomar , please try: You just need to set $ilovepdf->timeoutLarge = timeout_seconds;
In you case you only need to uncomment line // $ilovepdf->timeoutLarge = 606060;
And remove the line \Ilovepdf\Request::timeout(60*60*60*10);
This $ilovepdf->timeoutLarge
sets the CURLOPT_TIMEOUT for the /upload, /process and /download resources that are the ones that can delay more.
Hello @marcogrossisas, thanks for your reply and suggestion. I already tried all such things whichever is mentioned in the code, all the P&C I've done. So that include uncommenting of the // $ilovepdf->timeoutLarge = 60*60*60;
too.
But nothing is working I'm always getting the same error. I've checked from the library code and updated $ilovepdf->sendRequest()
method to see what actually going on inside the library.
But that too doesn't worked.
Hello @developerrajtomar it is strange, only to confirm it is an issue with the library please replace the lines 352, 353, 354 of ilovepdf-php/src/Request.php
if (self::$socketTimeout !== null) {
curl_setopt(self::$handle, CURLOPT_TIMEOUT, self::$socketTimeout);
}
with:
curl_setopt(self::$handle, CURLOPT_TIMEOUT, 60);
Try it and please report us if the problem is fixed. Thank you!
Hello @marcogrossisas thanks for this tweak. I tried this too. I think this is working fine Because I'm not getting that error anymore but still I got different errors. Attached a screenshot of Error.
This new error is due to permission problems when the library tries to save the downloaded file in the local folder, please check the permissions of the current folder or define a path when calling $myTask->download(path);
to a folder with enough permissions.
Regarding the previous error, remember this is only a temporary fix, we will set a higher default timeout.
That I understood, but the thing is, this is working only in 777
mod, none other is working. I'm getting same Permission error
with all other possible values, which is not good.
Secondly, If I tried to move the download file path from out side the project folder than I'm getting
An error occured: Invalid download path. Use method setOutputFilename() to set the output file name.
I tried to use $myTask->setOutputFilename($file1->filename);
as suggested by the error which doesn't work.
If inside the project folder and with, mod
777
that will cause a security issue.
So how to solve this issue?
Hi,
when setting the $myTask->download(path); the path must do not include the filename, only the route to the folder.
This problem is a permission and users issue, if you create a new folder outside the project you can chmod 777 that folder, or even better making this folder owner the webserver user (so you don't need to make it 777). This should work.
I've done exactly what you're expecting, but facing the issue after that too.
Hello @developerrajtomar we are sorry you are still having issues, but this are permission issues, not related with the library. We should close the issue opened.
Hi @marcogrossisas Thanks for your time. You can close this ticket and I will explore more about this permission issue. If it works fine than no issue else I'll create one more ticket for this Permission Error issue. And please make sure to provide an option for setting a timeout from the API's in the future release instead of this temporary fix.
Once again many thanks. Raj Tomar
Will do it! Thanks to you,
Hi All,
I tried to use this library, I'm getting the timeout exception. I debugged the issue upto some level and found that the issue is coming from the DownloadTask of the library and throws DownloadException as a time out.
$ilovepdf = new \Ilovepdf\Ilovepdf('public_key','secret_key'); // $ilovepdf->timeoutLarge = 60*60*60; // $ilovepdf->timeout = 60*60*60; $myTask = $ilovepdf->newTask('compress'); $file1 = $myTask->addFile('pdfs/08951505120104739-page_full.pdf'); try { \Ilovepdf\Request::timeout(60*60*60*10); // \Ilovepdf\Request::timeout(10); $myTask->execute(); $myTask->download(); echo "done"; } catch (\Ilovepdf\Exceptions\StartException $e) { echo "An error occured on start: " . $e->getMessage() . " "; // Authentication errors } catch (\Ilovepdf\Exceptions\AuthException $e) { echo "An error occured on auth: " . $e->getMessage() . " "; echo implode(', ', $e->getErrors()); // Uploading files errors } catch (\Ilovepdf\Exceptions\UploadException $e) { echo "An error occured on upload: " . $e->getMessage() . " "; echo implode(', ', $e->getErrors()); // Processing files errors } catch (\Ilovepdf\Exceptions\ProcessException $e) { echo "An error occured on process: " . $e->getMessage() . " "; echo implode(', ', $e->getErrors()); // Downloading files errors } catch (\Ilovepdf\Exceptions\DownloadException $e) { echo "An error occured on process: " . $e->getMessage() . " "; echo implode(', ', $e->getErrors()); // Other errors (as connexion errors and other) } catch (\Exception $e) { echo "An error occured: " . $e->getMessage(); }
An error occured: Operation timed out after 10019 milliseconds with 376283 out of 1617933 bytes received
Can anyone please help me to overcome from this problem?