Callout timeout exceeded error when trying to download aspose document as pdf using aspose words cloud api

We are trying to generate document that is generated by mail merge, but when we try to do so we have callout time exceeded error in salesforce(120 seconds limit in salesforce). Is this because it taking too much time to download the doucment from the apose also is there any work around for this issue?

Also another quick question when we perform a mail merge operation the document is generated as both pdf and doc right and when we try to download it we directly download the pdf version or the word version will be converted to pdf then we download it?

@skitzosiva

The “callout timeout exceeded” error you’re encountering in Salesforce when trying to download a document as a PDF using the Aspose.Words Cloud API may be due to the processing time required for generating the document, particularly if it involves a mail merge operation. Salesforce has a 120-second limit for callouts, and if the document generation exceeds this time, it will result in a timeout.

To work around this issue, consider the following options:

  1. Optimize Document Size and Complexity: Simplifying the document or reducing its size can help decrease processing time.

  2. Asynchronous Processing: Implement an asynchronous approach where the document is generated in the background. You can notify Salesforce when the document is ready for download, thus avoiding the timeout.

  3. Chunking: If the document is large, consider breaking it into smaller parts and processing them separately to manage the load more effectively.

Regarding your second question, when performing a mail merge operation, the document can be generated in both PDF and DOC formats. If you download the PDF version directly, it is generated from the mail merge output. If you download the Word version, it will be converted to PDF before downloading, depending on your API call.

For further details on memory requirements and processing times, please refer to the official Aspose documentation.

If you call the Aspose API from Salesforce, please consider using the mirror, which was created for Salesforce. For some reason, we don’t know why direct requests from Salesforce are sometimes not even received by our servers; they sink somewhere in Salesforce.
The mirror is https://api-mirror.aspose.cloud, so you need to add this URL to the Site Remote
Speaking of the second part of your request:
MailMerge does not perform conversion, so if your template is docx, then the result will also be docx.
If you use /storage/file to download the result file, it also doesn’t perform the conversion. So if you want to convert the resulting file, you need to use that endpoint Aspose.Words Cloud - API References

I don’t understand exactly can you please explain what is the mirror thing that you just said and if we have a custom aspose url how url like below how to change it like you mentioned,
We perform the mailmerge on the word document and we try to download as pdf as below: ( we dont perform any explicit conversion before this)

we perform get call using the below url to download the file
|https://aspose-abc.xyz-network.com/v4.0/words/GeneratedFileNameOnAspose?format=pdf

I don’t know what custom URL you use or how you set this up, but I think your custom URL somehow points to the https://api.aspose.cloud URL, right? If so, you need to point not to https://api.aspose.cloud but to https://api-mirror.aspose.cloud, which uses a different network to avoid issues with Salesforce.
The URL you shared is exactly what I refer to in reference to this endpoint, which does a conversion before sending the result file.

It not like all of our calls are not received by aspose, our initial calls for getting fieldNames from the template and all are working fine ( we get response) but only when we try to download the file we get timeout error (120 seconds salesforce) is this because of the conversion taking too long or the call isn’t received by aspose itself?

Please share the file you’re trying to convert. Sometimes, files have a complex structure, and it might take some time to convert, but downloading itself is a pretty straightforward operation and usually doesn’t require a lot of time

I’ll ask for the file from my team, meanwhile is there any cleanup option to remove all the mergefields from the generated document before trying to convert and download will this reduce the time? I believe we have seperate docker for this aspose service(i’m dont have more info on this for now ill 'ask my team) and i believe thats the reason our base url is different, if so how to change it to the mirror one

Please clarify what product you use? Aspose Words Cloud, or the self-hosted DockerHub version?