Required changes
To set up a WebSocket endpoint, you need to configure your app to use a custom runtime. Below is an example of the required changes in yourcerebrium.toml
configuration file:
- port: The port your app will listen on inside the container
- entrypoint: The command to start your app. In this example, we’re using Uvicorn to run a FastAPI app located in
main.py
healthcheck_endpoint
: The endpoint used to confirm instance health. If unspecified, defaults to a TCP ping on the configured port. If the health check registers a non-200 response, it will be considered unhealthy, and be restarted should it not recover timely.readycheck_endpoint
: The endpoint used to confirm if the instance is ready to receive. If unspecified, defaults to a TCP ping on the configured port. If the ready check registers a non-200 response, it will not be a viable target for request routing.
Things to note
- Custom Runtime Required: A custom runtime is necessary to set up a WebSocket endpoint because it allows you to define how your app is run inside the container
-
WebSocket URL: Requests need to be made to a WebSocket URL starting with
wss://
. Ensure that your client supports secure WebSocket connections