You can add the timeout
parameter to your upload call to override the maximum amount of time to wait for a response from Cloudinary before the connection is terminated through the SDK.
For example:
Rails:
Cloudinary::Uploader.upload('my_image.jpg', timeout:60)
PHP v1:
\Cloudinary\Uploader::upload('my_image.jpg', ["timeout" => 60]);
PHP v2:
$cloudinary->uploadApi()->upload('my_image.jpg',["timeout" => 60]);
IOS:
uploader upload:@"my_image.jpg"options:@{@"timeout": @"60"}]
.NET (global variable):
cloudinary.Api.Timeout = 60000;
If the above does not work for .NET, you may also need to set the Client side timeout via
cloudinary.Api.Client.Timeout = 60000;
Python:
uploader.upload("my_image.jpg", timeout=0.001)
UPDATE:
Node.js (v2):
cloudinary.v2.uploader.upload('my_image.jpg', {timeout:60000}, function(error,result){});
Please note: the timeout parameter is currently only supported when using one of the SDKs. You can read more about the timeout parameter in the Upload API documentation.
If timeouts still persist, please open a support ticket.
Comments
16 comments
Hi,
How set this limit in .NET?
Thanks
Changing the timeout on our .NET libraries is still not supported. Default value is 100000 milliseconds (=100 seconds).
As the libraries currently use the WebRequest class for HTTP client, you can dive into the code to implement this on your own. We will update here once it becomes officially supported.
UPDATE: customizing
timeout
within our .NET libraries is now supported as well.Hey nadav, the node.js update that you just added has an error in syntax. The {timeout:60000} is supposed to come after the callback function
Hi Navjeet, this syntax relates to the .v2 syntax, e.g.:
var cloudinary = require('cloudinary').v2;
What time unit is the timeout measured in? In some examples it's 60, others 60000. I assume 60 is in seconds, but 60000 is milliseconds? Why is the unit different between different languages?
Is it possible to set a default timeout anywhere? Using Django Admin's CloudinaryField it doesn't seem like it's easy to override a timeout since we don't directly access the uploader.
Hi Richard.
There is currently no way to implement a global timeout like you say.
We do have an open request with our dev team to allow more access in CloudinaryField and the timeout is one of them.
As soon as there are any insights regarding this I would let you know.
The implementation in seconds and milliseconds is different because the languages and SDKs are different, Some of our libraries perfromed better with milliseconds implementation so we chose that.
In other cases the default was seconds so we wanted to conform to the default.
Hope that helps.
Hi Nadav,
Hi Said,
We will need more information in order to investigate this issue. Can you please share the code snippet and your cloud name and we will be able to check further. If privacy is a concern, then please feel free to open a support ticket at support@cloudinary.com.
Regards,
Aditi
Hi Aditi,
My source codes:
https://github.com/jahanalem/DatingApp/commit/dc880a46cb22b505a824b6612a67c4279e87d37d
a screenshot from the error:
https://stackoverflow.com/questions/66164246/cloudinarydotnet-stream-readtimeout-threw-an-exception-of-type-system-invalid
Regards,
Said
Hi Said,
Thanks for sharing that.
Looking at the code, the one thing that may cause timeouts from the Cloudinary side, depending on the size of the file you are uploading, is the fact you're requesting an incoming transformation based on the following line: https://github.com/jahanalem/DatingApp/commit/dc880a46cb22b505a824b6612a67c4279e87d37d#diff-56a13120aebd0d27d86b06af7efb1b1d5cec2bb5f26f0df337f061392c940cb3R36
Since you aren't passing the 'Async' parameter set to true this transformation is attempted to be run synchronously on Cloudinary which will increase the processing time and that may be the cause of the errors you're seeing.
The ` UploadAsync` method makes the upload async on the client-side meaning your code doesn't stall until it gets a response, but this doesn't control the sync vs async processing of the transformation on Cloudinary.
As a first step, may I please ask you to pass the 'Async' parameter set to true in your `ImageUploadParams` and test again?
In addition, from the error you are receiving, I suspect the timeout isn't coming from the SDK but rather coming from the line before the upload: https://github.com/jahanalem/DatingApp/commit/dc880a46cb22b505a824b6612a67c4279e87d37d#diff-56a13120aebd0d27d86b06af7efb1b1d5cec2bb5f26f0df337f061392c940cb3R32
Could you also please verify that there is data coming through on that stream?
Lastly, could you try uploading by passing the path to that file from disk rather than a stream, does that work?
Thanks it's work..
Hello everyone,
What version of sdk for nodejs do we have timeout property? Version 1.23.0 doesn't have that timeout property.
Hi,
Thanks for reaching out.
Let me check the exact version, but can you expand on the type of error you are getting and what size of assets are you uploading to Cloudinary?
Best regards,
Igor
Hi,
It appears that v1.23 should support a "timeout"parameter - please implement the following: cloudinary.v2.uploader.upload('my_image.jpg', {timeout:60000}, function(error,result){});
If you are running into any issues, could you please provide us with your code so that we can troubleshoot deeper?
Thanks,
Jackie
Hello Jackie,
Looking in the file node_modules/cloudinary/types/index.d.ts the interface UploadApiOptions doesn't contain timeout.
The error that I am getting is
error: { message: 'Timeout waiting for parallel processing.', name: 'Error', http_code: 420 }.
Currently I am using v1.23.
Kind regards,
Ionut
Hi Ionut,
Thanks for sending the error message, really helpful.
What kind of asset are you trying to upload? If it's a big image/video then we recommend that you use eager_async: true as the error you're seeing is due to a previous operation that is still in progress on the asset.
If possible can you share more details about your asset like size, type, format, and if eager_async: true helped or not?
Thanks,
Kushal
Please sign in to leave a comment.