51120: Twilsock: Token is not valid yet
ERROR
This error occurs when a Twilsock connection tries to authenticate with an Access Token before the token's validity window begins. Twilio Access Tokens can include an optional nbf claim that defines the earliest time the token is accepted.
- The token's
nbfclaim is set to a future Unix timestamp. - The system clock on the token-issuing host is ahead or behind the validating system, which makes the token appear too early for use.
- Your client attempts to initialize the SDK immediately with a token that is not yet valid.
- Remove the
nbfclaim if you do not need a delayed start time. - If you use
nbf, set it to the current epoch time so the token is valid as soon as your client receives it. - Verify the system time on the machine that generates the token and correct any clock drift before issuing new tokens.
- Generate a fresh Access Token closer to the time of use.
- Create and sign Access Tokens with a Twilio helper library to ensure the token structure and claims are generated correctly.
- For long-lived client sessions, renew tokens before they expire by handling your SDK's token refresh events.