Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.38 KB

File metadata and controls

47 lines (38 loc) · 1.38 KB

RENDER DEPLOYMENT FIX - SocketIO Gevent Configuration

Issue

Render was defaulting to gthread worker instead of gevent, causing WebSocket failures:

RuntimeError: The gevent-websocket server is not configured appropriately
gunicorn -w 2 -k gthread  # ❌ Wrong worker type

Solution Applied

1. Enhanced Procfile

Updated from:

web: gunicorn -w 2 -k gevent --worker-connections 1000 --timeout 60 main:app

To:

web: python -m gevent.monkey --patch-all && gunicorn --worker-class gevent --workers 2 --worker-connections 1000 --timeout 120 --bind 0.0.0.0:$PORT --preload --max-requests 1000 --max-requests-jitter 100 main:app

2. Fixed Requirements

Added missing gevent dependency:

gevent==24.2.1
gevent-websocket==0.10.1

3. Enhanced main.py

  • Added gevent monkey patching at the very start
  • Enhanced SocketIO configuration with explicit logging and timeout settings

4. Environment Variables

Created .env.example with gevent-specific configuration variables.

Deployment Steps

  1. Commit these changes
  2. Push to GitHub
  3. Render will automatically detect the new Procfile and requirements
  4. The explicit worker-class specification should force gevent usage

Verification

After deployment, check logs for:

  • gunicorn --worker-class gevent (not gthread)
  • No "gevent-websocket server is not configured" errors
  • SocketIO connections working properly