Skip to content
Notifications
Clear all

Troubleshooting: API keeps timing out on >30 second generation jobs.

2 Posts
2 Users
0 Reactions
29 Views
(@observability_owl)
Eminent Member
Joined: 6 months ago
Posts: 19
Topic starter   [#1060]

Hey folks, ran into a real head-scratcher last night and wanted to share the pattern in case anyone else is hitting this. I've been using Resemble's API for batch-generating longer narration clips (think 2-3 minute audio). Anything under 30 seconds works flawlessly, but the longer jobs consistently timeout after exactly 30 seconds, returning a 504. My initial thought was a simple client-side timeout, but digging deeper showed it was server-side.

Here's the core of my initial script that was failing:

```python
response = requests.post(
'https://app.resemble.ai/api/v2/projects/{project_uuid}/clips',
json=payload,
headers={'Authorization': f'Bearer {API_KEY}'},
timeout=120 # Client timeout set to 120 seconds
)
```
Even with a generous client timeout, the Resemble backend seems to have a gateway or load balancer enforcing a 30-second limit on request processing. The job *might* still be processing after the timeout, but you lose the connection.

The workaround I landed on, after some trial and error and talking to support, is to use the **async workflow** for any generation you suspect might exceed 30 seconds. The steps:

1. Initiate the generation with a POST, which returns quickly with a `clip_uuid`.
2. Poll the `/clips/{clip_uuid}` endpoint (with your own, more forgiving client timeout) until the status is no longer `processing`.
3. Fetch the audio URL once it's `succeeded`.

It adds a few more lines of code, but it's rock-solid. My polling logic looks something like this:

```python
while True:
clip_status = get_clip_status(clip_uuid)
if clip_status['status'] in ['succeeded', 'failed']:
break
time.sleep(3) # Poll every 3 seconds
```

**Key takeaway:** Treat any generation over, say, 20 seconds as a long-running job and use async patterns from the start. I've also set up a small dashboard to monitor these async job durations and failure ratesβ€”because of course I did 🦉.

Has anyone else encountered this? What's your preferred polling interval or fallback strategy for failed async jobs?

--- hoot


Silence is golden, but only if you have alerts.


   
Quote
(@saas_selector_emma)
Eminent Member
Joined: 7 months ago
Posts: 18
 

Interesting! I haven't hit this exact issue with audio, but that 30-second gateway timeout pattern sounds familiar from a different service I tried for document processing. It's frustrating when it's a silent server limit, not your client setup.

So for the async workflow, do you have to poll a separate status endpoint to check if the longer clip is done, and then fetch it? That adds a few steps to the logic. I'm curious if you lose any debugging visibility compared to a simple synchronous call.


Small team, big decisions


   
ReplyQuote