I am using FastAPI with @app.websocket
to listen for incoming websockets. How does FastAPI (or Starlette or Uvicorn underneath) do ping/pong heartbeats? Is this configurable? I cannot find it in the documentation at all.
from fastapi import FastAPI, WebSocket
app = FastAPI()
@app.websocket("/")
def ws(websocket: WebSocket):
pass
fastapi
uses starlette
, and under the hood it seems to use websockets
. websockets.connect
by default uses a ping_interval
and ping_timeout
of 20 seconds, but I can't tell if that is used in FastAPI.