solve this ConnectionError: could not establish si...
# ask-ai
m
solve this ConnectionError: could not establish signal connection: invalid token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSmVzc2UgTGluc29uIiwibWV0YWRhdGEiOiJ7XCJ1c2VyX3R5cGVcIjogXCJjdXN0b21lclwiLCBcInJvb21fbmFtZVwiOiBcImJkNzEtNWMzZC02YmQ1XCIsIFwiZW52aXJvbm1lbnRcIjogXCJQUk9EXCJ9IiwidmlkZW8iOnsicm9vbUpvaW4iOnRydWUsInJvb20iOiJiZDcxLTVjM2QtNmJkNSIsImNhblB1Ymxpc2giOnRydWUsImNhblN1YnNjcmliZSI6dHJ1ZSwiY2FuUHVibGlzaERhdGEiOnRydWUsImNhblVwZGF0ZU93bk1ldGFkYXRhIjp0cnVlfSwic3ViIjoiY3VzdG9tZXJfamVzc2UrOTA1OTQzNEBib29rdmlkLmNvbSIsImlzcyI6IkFQSXdiUUZVZ3BKUUVvUSIsIm5iZiI6MTc1MjIwMzA3NiwiZXhwIjoxNzUyMjI0Njc2fQ.4iJkK1wn0Gu1zPS6ZQso67HBfxomKdyF5OsMT16HkDY, error: go-jose/go-jose: error in cryptographic primitive
t
Thanks for reaching out, Jesse. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The error ConnectionError: could not establish signal connection: invalid token with
go-jose/go-jose: error in cryptographic primitive
indicates an authentication failure during token verification. This typically happens due to one or more of the following: • Incorrect API key or API secret: Ensure your API key and secret match exactly what is configured in your LiveKit server—watch for hidden characters or trailing spaces. • Secret encoding issues: Special or non-ASCII characters in the API secret may cause cryptographic errors. Make sure your secret is properly encoded using the recommended method (
new TextEncoder().encode(secret)
). • Token structure or algorithm mismatch: Tokens must be signed using the
HS256
algorithm and include all required claims (especially
exp
,
iss
, and
identity
for room access). • Token expiration: Ensure the
exp
claim is valid and the system clocks on your server and client are synchronized. Troubleshooting steps: 1. Regenerate your JWT token server-side, ensuring the API key/secret and token claims are correct. 2. Decode your JWT token to verify it has
exp
(expiration),
iss
(issuer matching your API key), and any required video grants. 3. If possible, use the
TokenVerifier
utility from the SDK to test your token before attempting to connect. 4. Double-check your token is not expired and the correct algorithm/key is used throughout the process. If you can share your token generation code (with secrets redacted), I can help review for potential issues. Let me know if you need detailed steps for any of these or if the problem persists after checking these points. Sources: packages/livekit-server-sdk/src/AccessToken.ts | spec/livekit/token_verifier_spec.rb | Authentication | LiveKit Docs | errors.go | lib/src/core/signal_client.dart | src/room/Room.ts | livekit-api/src/test_token.txt | Web and mobile frontends | LiveKit Docs