Skip to content

CRITICAL: WebSocket background loop never starts #13

@Sszmentor

Description

@Sszmentor

Bug

server.py:356 calls asyncio.create_task(websocket_manager.connect()) but start_background_task() is never called. The WS manager connects but _background_loop (which reads messages, handles reconnects) never runs. Real-time subscriptions silently receive nothing.

Fix

Call websocket_manager.start_background_task() after connect, or merge connect+loop into one coroutine.

Also fix

  • websocket_manager.py:261-265: WS auth sends POLYMARKET_PASSPHRASE for both secret and passphrase fields. Should use separate POLYMARKET_API_SECRET env var for secret.
  • _background_loop uses asyncio.wait(FIRST_COMPLETED) which starves one channel under load. Use two separate tasks instead.

Files

  • src/polymarket_mcp/server.py:356
  • src/polymarket_mcp/utils/websocket_manager.py:261-265, 786-832

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions