ให้ช่วยอะไรได้บ้าง

แจ้งเรื่องสั้น ๆ เราจะติดต่อกลับทางอีเมล

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
ไปหน้าหลัก

Transport: WebSocket, HTTP fallback and reconnecting

How the widget talks to the chat server – addresses, subprotocol rc.v1, frame format, error and close codes, limits, reconnecting with seq and deduplication, and the HTTP fallback via Server-Sent Events and long polling.

This page describes what happens between the widget in the browser and the chat server. You need it for troubleshooting (network tab of the developer tools), for proxy and firewall rules and for your Content Security Policy.

Important: the wire protocol is the interface between our widget and our server. Custom clients that speak the protocol directly are not officially supported; fields may be extended within protocol version 1. For your own interfaces use the JavaScript API, for server connections webhooks and the server API.

Addresses

How the widget finds the WebSocket address:

  1. data-rc-ws-url on the loader tag, window.ReactiveChatSettings.wsUrl or ReactiveChat('boot', { wsUrl }) – if set, this value applies.
  2. Otherwise it is derived from the location of loader.js: wss://ws. + the last two labels of the domain + /rc_wss/. cdn.reactive.chat becomes wss://ws.reactive.chat/rc_wss/.

Two pitfalls follow from this:

The WebSocket route does not evaluate query parameters.

Establishing the connection

Frame format

Every message in both directions has this form:

{ "v": 1, "t": "msg", "id": "01JAB3C4D5E6F7G8H9JKMNPQRS", "ts": 1792500000000, "d": { } }

Unknown types and unknown fields are silently ignored – this keeps older widgets compatible with newer servers.

Message types at a glance

From the widget to the server:

From the server to the widget:

Error codes

An error arrives as a frame t: "error" with d.code, d.message (English, for developers only), d.retry (no, immediate, backoff, after_reinit) and, where needed, d.retry_after_ms and d.detail. The list is closed; an unknown code is treated like internal.

Close codes

Limits per connection

The server sends the binding values in init_ok.limits and init_ok.features:

Reconnecting, order, duplicates

HTTP fallback

If a network does not let a WebSocket through, the chat continues over ordinary HTTPS requests – with the same frames and the same limits. Only the widget uses it; the agent interface always connects via WebSocket. The short version for editors is under HTTP fallback.

When it applies:

Without fetch in the browser there is no fallback. If an existing WebSocket connection drops, the widget reconnects via WebSocket. After a fallback, it quietly checks once per page whether a WebSocket now gets through; if it does, it deletes rc_http, and the next page uses the WebSocket again.

The requests (under https://ws.reactive.chat/rc_wss/h/):

The widget tries SSE first; if no first frame arrives within 5 seconds (for example because a proxy buffers), it switches to long polling. It treats errors such as 404 (unbekannt), 403, 413 or 429 like a dropped connection and retries with a delay. After 60 seconds without a request, the server closes the connection. CORS: Access-Control-Allow-Origin mirrors the origin, without credentials; the origin check takes place in init, as with the WebSocket.

Requirements on your side:

Stored in the browser: only the entry rc_http in sessionStorage with the time of the HTTPS connection, without personal data.

Which route is active

In the network tab of the developer tools:

Next: Limits and quotas · Troubleshooting

อัปเดตล่าสุด: