Websocket app bursting received data instead of in real time

I have a websocket app that gets real time data through a polygon (ethereum) websocket:

async def get_event():
async with connect(infura_ws_url) as ws:
await ws.send(rpc)
subscription_response = await ws.recv()

    while True:
            message = await asyncio.wait_for(ws.recv(), timeout=150)
            response = json.loads(message)
            txHash = response['params']['result']

this app works with no issues locally: every 150 seconds I get the “waiting for message” print on the console if no messages.

When I deploy it to fly.io, I get the incoming messages in bursts. I get nothing on the monitoring page for 5/10 minutes, then suddenly a burst of messages, then nothing for 30/40min, then another burst.

How can I debug this issue?


1 Like

Figured it out. I was using print(). Changed to logging.info() and now all the logs are showing up in real time.

1 Like