rich-megabyte-73517
05/28/2026, 5:37 PMtall-airline-16756
05/28/2026, 5:37 PMtall-airline-16756
05/28/2026, 5:38 PMservice.stop_recording that shows a 401 and a JSON decode error. I’ll explain what it means and what to check next.
What the error means
• The StopEgress RPC call to https://…/twirp/livekit.Egress/StopEgress returned HTTP 401 (Unauthorized).
• The client expected a JSON response but the server returned plain text (text/plain; charset=utf-8), so the client failed to decode it and logged the MIME-type mismatch.
• In short: the request was rejected for authorization, and the error response wasn’t JSON so the client couldn’t parse it cleanly.
What to check next
• Verify the token used for the StopEgress call:
◦ Confirm the API key/secret pair used to sign the JWT matches the LiveKit project for that endpoint.
◦ Decode the JWT and check `nbf`/`exp` (not-before/expiry) and iss to ensure it’s for the correct project and not expired or not-yet-valid.
• Check for clock skew between the token issuer and the LiveKit server (can cause `nbf`/`exp` failures).
• Confirm you’re calling the correct LiveKit host/URL for that environment (dev vs prod) so keys match the project.
• If StopEgress is sent from a service, ensure it’s using current credentials (not a cached or rotated/invalid secret).
If you want, send:
• the egress_id (EG_FS6tXE2HniGB) and the token or decoded token payload (don’t share secrets) — I can point to which claim likely caused the 401,
• or tell me whether the stop request is issued from a server process that recently had its credentials rotated.
I can walk through decoding the token and the exact claims to inspect if you share the decoded JWT payload.
Sources: Troubleshooting 401 Unauthorized and Token Errors | LiveKit, with interactive elementsrich-megabyte-73517
05/28/2026, 5:40 PMtall-airline-16756
05/28/2026, 5:40 PMiss are correct.
• Ensure the service refreshes tokens and isn’t using a cached/rotated secret.
• Verify system clocks on token issuers and callers are in sync (NTP).
• If retries are not in place, consider retrying StopEgress on 401 once (with short backoff) since it can be transient.
If you’d like, I can:
• Help inspect a decoded JWT payload (not the secret) to point to the problematic claim, or
• Review whether your service is using cached credentials or needs a retry on transient auth failures.
Which would you prefer?
, with interactive elementsrich-megabyte-73517
05/28/2026, 6:12 PMtall-airline-16756
05/28/2026, 6:12 PMiss.
• Add a single retry with short backoff for StopEgress on 401 if you don’t already have retries.
If you want, I can:
• Inspect a decoded JWT payload (don’t share private keys) to point out problematic claims, or
• Check whether your service may have briefly used rotated credentials.
Which would you like me to do?
, with interactive elementsrich-megabyte-73517
05/28/2026, 6:13 PMtall-airline-16756
05/28/2026, 6:13 PMnbf, exp), so token acceptance is time-sensitive. If the container host clock drifts (NTP not synced) a token can appear expired or not-yet-valid and produce intermittent 401s.
What to do:
• Ensure hosts issuing tokens and the LiveKit caller/server have synchronized clocks (enable NTP).
• Verify token TTLs aren’t too short.
• Add a short retry on 401 for transient auth failures.
• If you want, share a decoded JWT payload (no secrets) and I’ll point out any timing claims that look problematic., with interactive elementsrich-megabyte-73517
05/28/2026, 6:16 PMtall-airline-16756
05/28/2026, 6:16 PMnbf (JWT "not before"): a claim inside a JWT that says the token is not valid until the specified timestamp. If the server’s clock is earlier than the nbf time, the token will be rejected as “not yet valid.”
Why this matters for LiveKit
• LiveKit checks JWT time claims (nbf, exp). If clocks aren’t synced (NTP not running) or a token’s `nbf`/`exp` is off, requests can intermittently return 401 Unauthorized.
Would you like me to:
• Walk you through checking NTP on your hosts, or
• Inspect a decoded JWT payload (no secrets) to check `nbf`/`exp` values?, with interactive elements