Token Expiry Handling
FYERS tokens expire daily and can be invalidated by logging in from another device. This playbook explains how to detect and recover safely.
What Happened
- REST calls return auth errors (often code -8 or "token expired").
- WS reconnect loops without receiving data.
- History calls return empty data with "no_data" messages.
Why It Happens
- FYERS sessions expire at the end of the trading day.
- A new login on another device invalidates the previous token.
What To Check
logs/fyers_auth_errors.logfor AuthError entries.logs/fyers_ws_errors.logfor auth-related disconnects.- Recent token timestamp in
secrets/fyers_token.json.
What To Do Next
- Run
fyers-authto refresh the token. - Restart the Store/Broker/DataFeed process.
- Confirm live data and order WS updates resume.
Safety Notes
- Do not retry orders during auth failure.
- Do not allow reconnect loops to run unattended; fix auth first.
Scenario Example
Scenario: Backtest history returns empty bars.
What happened:
- The cached token expired and history calls degrade into no_data.
What to check:
- logs/fyers_rest_errors.log and the FYERS SDK logs.
What to do next:
- Refresh the token and re-run the backtest.