ChatNetworkConfig
ChatNetworkConfig groups the SDK's network settings and is used in the networkConfig field of ChatConfig.
Backend server addresses are configured separately in transport_config. Chat business settings (attachments, input field, push) live in chat_config.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
httpConfig | HTTPConfig | No (default) | HTTP client settings: connection, download, and upload timeouts |
wsConfig | WSConfig | No (default) | WebSocket connection settings: connection timeout, frame read/write timeout, ping interval |
sslPinning | SSLPinningConfig | No (default) | Pinning certificates and a flag to disable certificate validation |
All timeouts in HTTPConfig and WSConfig are in seconds.
Default values
| Class | Parameter | Default | Description |
|---|---|---|---|
HTTPConfig | connectionTimeout | 30 s | HTTP connection establishment timeout |
HTTPConfig | downloadTimeout | 30 s | File download timeout |
HTTPConfig | uploadTimeout | 30 s | File upload timeout |
WSConfig | connectionTimeout | 30 s | WebSocket connection establishment timeout |
WSConfig | sendTimeout | 30 s | WebSocket frame read/write timeout |
WSConfig | pingInterval | 30 s | Keepalive ping/pong interval |
WSConfig | isReconnectEnabled | false | Automatic WebSocket reconnect after a disconnect |
WSConfig | maxReconnectAttempts | 10 | Maximum number of reconnect attempts after a disconnect. Values below 1 are clamped to 1 |
Automatic WebSocket reconnect
When isReconnectEnabled = true, the SDK retries the WebSocket connection after a disconnect using exponential backoff: the interval between attempts doubles with each iteration (1, 2, 4, 8, 16, 32 seconds) and is capped at 60 seconds. With maxReconnectAttempts = 10, the total recovery window is approximately 5 minutes — after that, the SDK stops retrying and reports the error via ChatCenterUIListener.networkErrorReceived(error).
val networkConfig = ChatNetworkConfig(
wsConfig = WSConfig(
isReconnectEnabled = true,
maxReconnectAttempts = 10
)
)
While reconnect is in progress, the chat screen shows:
- the toolbar title "Connecting..." (string
ecc_chat_title_connecting); - the send and attach buttons are disabled until the connection is restored; text in the input field remains editable.
Queued messages. Messages sent by the user during the disconnect stay in the local database with status SENDING. After the connection is restored, the SDK continues working in the same session — calling authorize(user, auth) again is not required. If reconnect fails and attempts are exhausted, message statuses transition to FAILED, and the user can retry sending from the UI.
Background behavior. If the app moves to background during reconnect, the SDK keeps retrying within the standard Android constraints (Doze, App Standby). Background behavior also depends on ChatConfig.keepWebSocketActive — see Known limitations.
For production, enable automatic reconnect and keep the attempt count at its default value. This removes the need for custom logic to re-call authorize on transient network failures.
WSConfig(
isReconnectEnabled = true,
maxReconnectAttempts = 10
)
Set the parameter before calling init(...) / initAsync(...) — changes after initialization take no effect (see the general note "Changing settings" below). While isReconnectEnabled = true, chat state transitions are not interrupted by timeout — the final failure signal is the exhaustion of reconnect attempts and the networkErrorReceived event.
SSL Pinning
val networkConfig = ChatNetworkConfig(
httpConfig = HTTPConfig(),
wsConfig = WSConfig(),
sslPinning = SSLPinningConfig(
certificates = arrayOf(ChatSSLCertificate(R.raw.my_cert)),
allowUntrustedCertificates = false
)
)
SSLPinningConfig parameter | Type | Required | Default | Description |
|---|---|---|---|---|
certificates | Array<ChatSSLCertificate> | No | arrayOf() | Certificates for SSL pinning |
allowUntrustedCertificates | Boolean | No | false | Disable TLS certificate validation. Testing only |
Passing a non-empty certificates array together with allowUntrustedCertificates = true is not allowed: the SSLPinningConfig constructor throws IllegalArgumentException.
Allowed combinations:
certificates = arrayOf(...)+allowUntrustedCertificates = false— production with SSL pinning;certificates = arrayOf()(default) +allowUntrustedCertificates = true— test environment only;certificates = arrayOf()+allowUntrustedCertificates = false— standard TLS validation without pinning (default values).
Set ChatNetworkConfig fields before calling init(...) / initAsync(...). SDK behavior when settings are changed after initialization is undefined.
Related sections
- ChatConfig — where
networkConfigis passed. - SDK known limitations.
- Troubleshooting → WebSocket disconnects — diagnosing frequent reconnects.