I Have been merge files in the same way for years. Now all of the sudden i get an error when i merge the files as so:
raise ApiException(http_resp=r)
asposeslidescloud.rest.ApiException: (504)
Reason: Gateway Time-out
HTTP response headers: HTTPHeaderDict({'Date': 'Sun, 04 Aug 2024 04:13:58 GMT', 'Content-Type': 'text/html', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'cache-control': 'no-cache'})
HTTP response body: b"<html><body><h1>504 Gateway Time-out</h1>\nThe server didn't respond in time.\n</body></html>\n\n"
This is the code i use
request = OrderedMergeRequest()
request.presentations = presentaionsArray
response = slides_asyncapi.merge_and_save_online(
"MyPresentation.pptx", None, request, "internal")
The files are all 20-30MB and i have been doing the same operation with the same code for at least 2 years.
I switched to async after these issues came and it works every once in a while but mostly it just gets stuck in the “Created” status and never gets to the started point. Very frustrating.
It seems you are encountering a “504 Gateway Time-out” error when trying to merge large presentation files using Aspose. This type of error typically indicates that the server is taking too long to respond, which can happen with larger files, especially those in the 20-30MB range that you mentioned.
Here are a few suggestions to help you troubleshoot and potentially resolve this issue:
-
File Size Considerations: Since you are working with larger files, consider splitting the presentations into smaller segments before merging them. This can help reduce the processing time and avoid time-out errors.
-
Timeout Adjustments: Check if there are any settings in your API configuration that allow you to increase the timeout duration. This could provide the server with more time to process your request.
-
Asynchronous Processing: You mentioned switching to asynchronous processing, which is a good approach. However, if the status remains “Created” for an extended period, it may indicate that the server is still struggling to process the request. Ensure that your implementation correctly handles the asynchronous response and checks for any errors.
-
Error Handling: Implement robust error handling in your code to manage cases where the server does not respond in time. This can include retrying the request after a certain interval or logging the error for further analysis.
-
Contact Support: If the issue persists, consider reaching out to Aspose support for assistance. They may provide insights specific to your account or the current server status.
Here’s a modified version of your code that includes basic error handling:
from collections import OrderedDict
import time
def merge_presentations(presentations_array):
request = OrderedMergeRequest()
request.presentations = presentations_array
for attempt in range(3): # Retry up to 3 times
try:
response = slides_asyncapi.merge_and_save_online("MyPresentation.pptx", None, request, "internal")
if response.status == "Completed":
print("Merge completed successfully.")
return response
elif response.status == "Created":
print("Merge is still processing...")
time.sleep(10) # Wait before checking again
else:
print(f"Unexpected status: {response.status}")
break
except ApiException as e:
print(f"Error occurred: {e}")
time.sleep(5) # Wait before retrying
print("Merge failed after multiple attempts.")
This code attempts to merge the presentations and includes a simple retry mechanism. Adjust the sleep duration as needed based on your observations.
If you continue to experience issues, please provide any additional error messages or behaviors you observe, as this can help in diagnosing the problem further.