iam getting this error twirp error unknown: reques...
# ask-ai
n
iam getting this error twirp error unknown: request has missing or invalid field: ws_url when trying to upload the recording to s3 storage const fileOutput = new EncodedFileOutput({ filepath: fileName, output: { case: 's3', value: new S3Upload({ accessKey: AWS_ACCESS_KEY_ID!, secret: AWS_SECRET_ACCESS_KEY!, region: S3_REGION, bucket: S3_BUCKET_NAME, }), }, }); console.log('File output configuration:', JSON.stringify({ filepath: fileName, outputType: 's3', region: S3_REGION, bucket: S3_BUCKET_NAME }, null, 2)); // Use the exact method signature from your original working code console.log('Starting room composite egress...'); await egressClient.startRoomCompositeEgress( roomName, { file: fileOutput, }, { layout: 'speaker', }, );
t
Thanks for reaching out, Mohamed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like you're encountering the error "twirp error unknown: request has missing or invalid field: ws_url." This usually happens when the LiveKit Egress service can't find or validate the
ws_url
field in its configuration. This field is super important because it allows the egress service to connect to the LiveKit server using the WebSocket protocol. Here are a few steps that might help you fix this: • Double-check that the
ws_url
is correctly set in your egress configuration file or as the environment variable
LIVEKIT_WS_URL
. • If you're running this locally inside Docker, try using the host's IP address as Docker sees it (for example,
<ws://192.168.65.2:7880>
on macOS/Windows with Docker Desktop) instead of
localhost
. • For secure setups, it's best to use
wss://
instead of
ws://
, unless you have explicitly set
insecure: true
in your configuration. Please feel free to reach out if you'd like me to walk you through this or if you have any other questions. I'm here to help! Sources: pkg/config/base.go
n
the
ws_url
is not in your egress configuration and i dodnot have LIVEKIT_WS_URL in my nev
t
Thank you for reaching out! The
ws_url
is really important for the egress service to connect smoothly to the LiveKit server. I noticed it’s missing from your egress configuration, and since
LIVEKIT_WS_URL
isn’t set as an environment variable either, we’ll need to add it together. Here’s a simple way to move forward: • Add the
LIVEKIT_WS_URL
environment variable to your setup. For example:
LIVEKIT_WS_URL=<ws://your-livekit-server:7880>
. Just swap out
your-livekit-server
with your actual server address. • If you’re running the egress service locally, please make sure the
ws_url
points to the correct host IP address as Docker sees it (something like `ws://192.168.65.2:7880`). • For secure setups, it’s best to use
wss://
instead of
ws://
, unless you’ve specifically set
insecure: true
in your configuration. Once you’ve made these updates, just restart the egress service and give it another try. If you run into any other questions or need a hand, I’m here to help!
n
how to add
ws_url
to my egress configuration
t
To help you add the
ws_url
to your egress configuration, you’ll want to include it in the YAML configuration file under the top-level
ws_url
field. This tells the egress service which WebSocket URL of the LiveKit server to connect to. Here’s a simple example for you:
Copy code
ws_url: <wss://your-livekit-url.com>
Just replace
<http://your-livekit-url.com|your-livekit-url.com>
with the actual URL of your LiveKit server. Remember to use
wss://
for secure connections, or
ws://
if you’re using insecure connections (when
insecure: true
is set). If you prefer, you can also set the
LIVEKIT_WS_URL
environment variable instead of changing the configuration file. Once you’ve made these updates, please restart the egress service and give it another try. If you run into any issues or have questions, I’m here to help—just let me know! Sources: pkg/config/pipeline.go | Self-hosting the Egress Service | LiveKit Docs | egress-sample.yaml
n
how to add
ws_url
to my egress configuration // Use the same URL conversion as the original working code const hostURL = new URL(LIVEKIT_URL!); hostURL.protocol = 'https:'; console.log(
Egress URL: ${hostURL.origin}
); const egressClient = new EgressClient(hostURL.origin, LIVEKIT_API_KEY, LIVEKIT_API_SECRET); const existingEgresses = await egressClient.listEgress({ roomName }); if (existingEgresses.length > 0 && existingEgresses.some((e) => e.status < 2)) { return new NextResponse('Meeting is already being recorded', { status: 409 }); } // Generate simple filename for S3 upload const fileName = `livekit/record/${roomName}.mp4`; console.log(
Generated filename: ${fileName}
); const fileOutput = new EncodedFileOutput({ filepath: fileName, output: { case: 's3', value: new S3Upload({ _// accessKey: AWS_ACCESS_KEY_ID!,_ _// secret: AWS_SECRET_ACCESS_KEY!,_ region: S3_REGION, bucket: S3_BUCKET_NAME, }), }, }); console.log('File output configuration:', JSON.stringify({ filepath: fileName, outputType: 's3', region: S3_REGION, bucket: S3_BUCKET_NAME }, null, 2)); // Use the exact method signature from your original working code console.log('Starting room composite egress...'); await egressClient.startRoomCompositeEgress( roomName, { file: fileOutput, }, { layout: 'speaker', }, ); console.log('Recording started successfully');
t
Thanks for reaching out! I wanted to share that the
ws_url
can’t be set directly through the JavaScript SDK for LiveKit Egress. Instead, it needs to be configured within the Egress service itself. Don’t worry—I’ll guide you through how to do this: Option 1: YAML Configuration File You can add the
ws_url
to the Egress service’s YAML configuration file like this:
Copy code
api_key: your-api-key
api_secret: your-api-secret
ws_url: <wss://your-livekit-server.com>
redis:
  address: your-redis-address:6379
Then, just pass this file to the Egress service using the
EGRESS_CONFIG_FILE
environment variable. Option 2: Environment Variable Alternatively, you can set the
LIVEKIT_WS_URL
environment variable before starting the Egress service:
Copy code
LIVEKIT_WS_URL=<wss://your-livekit-server.com>
These steps will help ensure your Egress service connects to the right LiveKit server. If you have any questions or need a hand with the setup, please feel free to ask—I’m here to help! Sources: packages/livekit-server-sdk/src/EgressClient.ts | Track egress | LiveKit Docs | Self-hosting the Egress Service | LiveKit Docs | README.md
n
what about YAML Configuration File when using self-hosted egress service
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!