Skip to main content
Version: 5.21.0

ChatNetworkConfig

ChatNetworkConfig groups the SDK's network settings and is used in the networkConfig field of ChatConfig.

info

Backend server addresses are configured separately in transport_config. Chat business settings (attachments, input field, push) live in chat_config.

Parameters

FieldTypeRequiredDescription
httpConfigHTTPConfigNo (default)HTTP client settings: connection, download, and upload timeouts
wsConfigWSConfigNo (default)WebSocket connection settings: connection timeout, frame read/write timeout, ping interval
sslPinningSSLPinningConfigNo (default)Pinning certificates and a flag to disable certificate validation

All timeouts in HTTPConfig and WSConfig are in seconds.

Default values

ClassParameterDefaultDescription
HTTPConfigconnectionTimeout30 sHTTP connection establishment timeout
HTTPConfigdownloadTimeout30 sFile download timeout
HTTPConfiguploadTimeout30 sFile upload timeout
WSConfigconnectionTimeout30 sWebSocket connection establishment timeout
WSConfigsendTimeout30 sWebSocket frame read/write timeout
WSConfigpingInterval30 sKeepalive ping/pong interval
WSConfigisReconnectEnabledfalseAutomatic WebSocket reconnect after a disconnect
WSConfigmaxReconnectAttempts10Maximum 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.

Recommended production configuration

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
)
Initialization order

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 parameterTypeRequiredDefaultDescription
certificatesArray<ChatSSLCertificate>NoarrayOf()Certificates for SSL pinning
allowUntrustedCertificatesBooleanNofalseDisable TLS certificate validation. Testing only
Forbidden parameter combination

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).
Changing settings

Set ChatNetworkConfig fields before calling init(...) / initAsync(...). SDK behavior when settings are changed after initialization is undefined.