Skip to main content
A web session can fail in three places:
Many problems show no error at all. The session connects and the agent never speaks. See Troubleshooting.

Creating a session

POST /api/v1/realtime/sessions runs these checks. If one fails, no session is created. The rate limit check runs last. So 402, 403, 404 and 422 do not use up a session.

Close codes

When the server refuses a connection, it accepts the WebSocket and then closes it right away with a code. No message is sent first. So onopen fires even when the connection is refused. Read event.code and event.reason in onclose.

4001: invalid token

All token problems return 4001 with the same reason. Check these in order:
  1. The token was already used. This is the most common cause during development. A token is used up by the first connection attempt, even if that attempt fails. Common causes:
    • React Strict Mode runs effects twice in development.
    • Hot reload runs the connect code again with the old token.
    • Your retry code reconnects with the same ws_url.
  2. The token expired. It lasts 60 seconds. Creating the session on page load and connecting later on a click can take longer.
  3. The URL was changed. Open ws_url exactly as returned.
  4. The agent was deleted or moved between creating the session and connecting.

4029: too many connections

Read the reason to tell the two limits apart.
  • Per-IP limit (20 attempts per 60 seconds). This check runs before the socket is accepted. So a browser usually reports code 1006 with an empty reason, not 4029. If your reconnect loop gets 1006, this is likely the cause.
  • Plan limit. A session holds a slot until it disconnects. Close sessions with ws.close(1000) and stop all media tracks, including on beforeunload. A tab closed without cleanup can hold its slot for up to 2 hours.

A 1000 close you did not expect

When the agent ends the conversation, the server sends session_ended. On voice, camera and screen sessions it does not close the socket. Call ws.close() yourself when you get session_ended. A 1000 close that you did not start, with no session_ended before it, gives you nothing to go on. Log the last error message and the last turn you received.

Error messages

During a session, the server sends an error message when it cannot use something you sent:
The session stays open. The server drops that one message and carries on. Do not end the session on an error. Log code and show it while you develop. Match on code. The error text can change.
no_audio_received is checked when an image arrives, not on a timer. It fires on the first image that arrives at least 8 seconds after the first one. If you send two images and stop, you never get it.

Text sessions

A text session only sends two of these codes: binary_frame_unsupported and missing_data. It ignores audio and images without any error. If you send invalid JSON, the agent replies with a normal-looking apology message instead of an error. Check your own JSON on text sessions.

Client library errors

session.start() rejects with an EclatiraError. Its code tells you what happened: