ruvnet/RuView · error · Exception

Failed to create stream: {response.status}

Error message

Failed to create stream: {response.status}

What it means

Spec code in plans/phase2-architecture/api-architecture.md: the streaming provider adapter (RestStreamIO-style) creates a broadcast over HTTP and, when the response status is not the expected success code, raises a generic Exception('Failed to create stream: {status}'). Only the numeric status surfaces — the provider's response body with the actual reason (auth failure, quota, invalid name) is never read, making diagnosis harder.

Source

Thrown at plans/phase2-architecture/api-architecture.md:1413

                f"{self.base_url}/streams",
                headers=headers,
                json=payload
            ) as response:
                if response.status == 201:
                    stream_data = await response.json()
                    stream_id = stream_data['id']
                    rtmp_url = stream_data['ingests']['rtmp']['url']
                    stream_key = stream_data['ingests']['rtmp']['stream_key']
                    
                    self.active_streams[stream_id] = {
                        'rtmp_url': rtmp_url,
                        'stream_key': stream_key,
                        'status': 'created'
                    }
                    
                    return stream_id, f"{rtmp_url}/{stream_key}"
                else:
                    raise Exception(f"Failed to create stream: {response.status}")
    
    async def start_pose_visualization_stream(self, stream_id: str):
        """Start streaming pose visualization"""
        if stream_id not in self.active_streams:
            raise ValueError(f"Unknown stream: {stream_id}")
        
        stream_info = self.active_streams[stream_id]
        rtmp_endpoint = f"{stream_info['rtmp_url']}/{stream_info['stream_key']}"
        
        # Start FFmpeg process for streaming
        ffmpeg_cmd = [
            'ffmpeg',
            '-f', 'rawvideo',
            '-pixel_format', 'bgr24',
            '-video_size', '1280x720',
            '-framerate', '30',
            '-i', '-',  # Input from stdin
            '-c:v', 'libx264',

View on GitHub (pinned to 4685618388)

Solutions

  1. Log/read the provider response body before raising — the status alone rarely explains 4xx rejections
  2. Verify provider credentials and that the base URL/region match the account
  3. Accept all 2xx codes (resp.status // 100 == 2), not just one expected code
  4. Retry with backoff on 5xx/timeouts; fail fast on 4xx after reading the body

Example fix

# before
else:
    raise Exception(f"Failed to create stream: {response.status}")  # reason discarded

# after
else:
    body = await response.text()
    logger.error("stream create failed: %s %s", response.status, body[:500])
    raise Exception(f"Failed to create stream: {response.status}: {body[:200]}")
Defensive patterns

Strategy: retry

Validate before calling

# Pre-flight the provider before starting a session
async def provider_ready(client) -> bool:
    resp = await client.get("/api/streams")  # cheap authenticated call
    return resp.status == 200  # credentials + reachability OK

Try / catch

for attempt in range(3):
    try:
        stream_id, url = await provider.create_stream(name)
        break
    except Exception as e:  # message carries the provider status code
        if "500" in str(e) or "timeout" in str(e).lower():
            await asyncio.sleep(2 ** attempt)
            continue
        raise  # 4xx will not heal — fix credentials/quota first

Prevention

When it happens

Trigger: POSTing the create-stream request with invalid/expired provider credentials (401/403), exhausted quota or plan limits (4xx), provider outage (5xx), egress blocked by firewall, or a 2xx code the code does not expect (e.g. 200 vs 201) which is treated as failure.

Common situations: Expired streaming API key; wrong provider region/base URL; corporate network blocking RTMP/API egress; provider changed its success status or response schema.

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/406f10b7c06df6d4. Report an issue: GitHub.