I'm using a self-hosted LiveKit setup and I want t...
# ask-ai
p
I'm using a self-hosted LiveKit setup and I want to test the custom template locally. How can I do that?
t
Thanks for reaching out, Yassine. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you test your custom template locally in a self-hosted LiveKit setup, you can use the
egress test-egress-template
subcommand from the LiveKit CLI. This handy command lets you create a room, add virtual publishers, and open a browser instance to your app URL with the right parameters—all set up for you! Here’s a simple way to get started and test: 1. First, make sure your custom template application is deployed and accessible through a URL. 2. Next, configure your LiveKit server with the needed details like
ws_url
,
api_key
, and
api_secret
. You can set these in environment variables or a config file—whichever works best for you. 3. Then, run the Egress service locally using a YAML configuration file. For example:
Copy code
api_key: your-api-key
api_secret: your-api-secret
ws_url: ws://192.168.65.2:7880
insecure: true
redis:
  address: 192.168.65.2:6379
After that, start the Egress service by running this command:
Copy code
docker run --rm \
    -e EGRESS_CONFIG_FILE=/out/config.yaml \
    -v ~/egress-test:/out \
    --cap-add=SYS_ADMIN \
    livekit/egress
Once the Egress service is up and running, you can use the CLI to test your custom template with your self-hosted setup. If you run into any hiccups, here are a few things to double-check: • Is Redis accessible and properly configured? • Does the
ws_url
resolve correctly from inside Docker? • Is Chrome sandboxing enabled by running the container with
--cap-add=SYS_ADMIN
? Please don’t hesitate to reach out if you need any more help—I’m here to support you every step of the way! Sources: Custom recording templates | LiveKit Docs | template-sdk/README.md | Self-hosting the Egress Service | LiveKit Docs | README.md
p
but the egress alreayd in production everything is in production only the custom template is local i think there is a token generated how to get that token from the server to put it in the local custom template param ?
t
Let's walk through how you can retrieve a token from your server to use in your local custom template: 1. First, make sure your production server has an endpoint set up for token generation. Usually, this is a REST API endpoint like
/token
that takes parameters such as
roomName
and
participantName
. 2. Next, from your local environment, you can send a
POST
request to this endpoint. Here's an example:
Copy code
curl -X POST <PRODUCTION_SERVER_URL>/token \
     -H "Content-Type: application/json" \
     -d '{"roomName": "my-room", "participantName": "user1"}'
This will give you a JWT token that you can then use in your local custom template. Also, please double-check that your production server’s token generation logic includes all the necessary permissions for what you need—like joining the room or publishing. If you run into any questions or want me to help you with the token generation or configuration, just let me know. I'm here to help! Sources: TEMPLATE.md | src/pages/api/token.ts | LiveKit CLI Setup | LiveKit Docs | README.md