The connection is killed by runpod for all request above ~1MB.
Ping @muhsinking @DeJayDev
Here's how to reproduce it:
#!/usr/bin/env python3
"""
FastAPI test server - JSON with base64 encoded image
"""
import asyncio
import base64
import logging
from fastapi import FastAPI, HTTPException
from fastapi.responses import JSONResponse
from pydantic import BaseModel
import uvicorn
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
app = FastAPI()
class ImageRequest(BaseModel):
"""Request model with base64 encoded image"""
image: str
prompt: str = "test"
max_resolution: str = "4k"
convert_to_bw: bool = True
@app.post("/predict")
async def predict(request: ImageRequest):
"""
Accept JSON with base64 image, wait 5 seconds, return base64 image
"""
try:
# Decode base64 image
try:
image_bytes = base64.b64decode(request.image)
except Exception as e:
raise HTTPException(status_code=400, detail=f"Invalid base64 image data: {str(e)}")
if len(image_bytes) == 0:
raise HTTPException(status_code=400, detail="Image data is empty")
logger.info(f"Received image: {len(image_bytes)} bytes, prompt: {request.prompt}")
# Wait 5 seconds to simulate processing
await asyncio.sleep(5)
# Encode image back to base64
image_b64 = base64.b64encode(image_bytes).decode('utf-8')
return JSONResponse(
content={
"image": image_b64,
"success": True
},
status_code=200
)
except HTTPException:
raise
except Exception as e:
logger.error(f"Error processing request: {str(e)}")
raise HTTPException(status_code=500, detail=f"Server error: {str(e)}")
@app.get("/ping")
async def health_check():
"""Health check endpoint"""
return {"status": "healthy"}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
Dockerfile
# V1.0.3
FROM python:3.11-slim
WORKDIR /app
# Install dependencies
RUN pip install --no-cache-dir \
fastapi \
uvicorn[standard] \
python-multipart
# Copy all test scripts
COPY app.py .
# Default command - rename the script you want to run as app.py
# Or override with: docker run <image> python3 <script_name>.py
CMD ["python3", "app.py"]
Working: (301 KB)
curl -X POST "endpoint_url" \
-H 'Authorization: Bearer Token' \
-H 'Content-Type: application/json' \
-d @small_request.json
Not-working: (3,4 MB)
curl -X POST "endpoint_url" \
-H 'Authorization: Bearer Token' \
-H 'Content-Type: application/json' \
-d @request.json
request.json
small_request.json
The connection is killed by runpod for all request above ~1MB.
Ping @muhsinking @DeJayDev
Here's how to reproduce it:
Dockerfile
Working: (301 KB)
Not-working: (3,4 MB)
request.json
small_request.json