Skip to content

Server–proxy communication timeouts

This document describes which configuration timeouts apply to each stage of server–proxy communication in Glaber. It reflects the current codebase (src/zabbix_server, src/zabbix_proxy, src/libs/zbxcomms, src/libs/zbxcommshigh).

Configuration parameters

Config file parameter C variable Default (code) Role
Timeout config_timeout 3 s Processing timeout for checks, scripts, modules, and short trapper JSON replies. Not intended for large proxy bulk transfers.
TCPTimeout CONFIG_TCP_TIMEOUT 10 s Short TCP/TLS operations: connect, TLS handshake, small request/response, trapper read of a single incoming message (see caveats below).
TrapperTimeout CONFIG_TRAPPER_TIMEOUT 300 s Long bulk transfers over an established connection: large config/history payloads, proxy data upload/download, proxypoller passive I/O.
ProxyConfigFrequency CONFIG_PROXYCONFIG_FREQUENCY 10 s (server/proxy) Schedule: how often config sync is attempted (not a per-socket I/O limit).
ProxyDataFrequency CONFIG_PROXYDATA_FREQUENCY 1 s (server) Schedule: how often the server proxypoller requests passive proxy data.
DataSenderFrequency CONFIG_PROXYDATA_FREQUENCY 1 s (proxy) Schedule: how often the active proxy datasender runs.
(hardcoded) CONFIG_PROXYCONFIG_RETRY 120 s (proxy only) Retry interval when active proxy cannot connect to the server for config (sleep between attempts).

Both glaber_server.conf and glaber_proxy.conf use the same parameter names (Timeout, TCPTimeout, TrapperTimeout, etc.).

How socket deadlines work

  • During zbx_tcp_send_ext() / zbx_tcp_recv_ext(), the timeout argument sets a per-operation deadline via zbx_socket_set_deadline().
  • The deadline is wall-clock seconds (time(NULL) + timeout), checked in non-blocking read/write loops and TLS handshake retries.
  • A single logical exchange (e.g. “send 100k values, then wait for ACK”) may involve multiple deadline windows if each call passes its own timeout.
  • ZBX_TCP_LARGE: receive path allows the large protocol (64-bit lengths, up to 16 GiB on non-Windows). Used where bulk proxy/config/history data is expected.

Proxy modes

Mode Who connects Config sync History / proxy data
Active Proxy → server (trapper) proxyconfig thread datasender thread
Passive Server → proxy (trapper) proxypollerzbx_recv_proxyconfig proxypollerzbx_send_proxy_data

Mode must match on both sides (UI proxy mode ↔ ProxyMode in glaber_proxy.conf). A mismatch produces misconfiguration errors or broken pipes, not just timeouts.


Active proxy (proxy initiates connection)

sequenceDiagram
    participant P as Proxy
    participant S as Server trapper

    Note over P,S: Configuration (proxyconfig thread)
    P->>S: TCP connect (Timeout=connect, TCPTimeout=socket property)
    P->>S: TLS handshake (same connect deadline)
    P->>S: Send config request (TrapperTimeout)
    S->>P: Send full config (TrapperTimeout, ZBX_TCP_LARGE)
    Note over P: Process config locally

    Note over P,S: History data (datasender thread)
    P->>S: TCP connect + TLS (TCPTimeout / Timeout)
    P->>S: Send proxy data (TrapperTimeout)
    Note over S: Receive message (TCPTimeout, ZBX_TCP_LARGE)
    Note over S: Process history (can take long)
    S->>P: JSON ACK (TrapperTimeout on proxy recv)

Active — configuration (proxyconfig.c → server zbx_send_proxyconfig)

Stage Direction Function / location Timeout Notes
Connect + TLS Proxy → server zbx_connect_to_server() connect_timeout = Timeout (3 s) TCP + TLS handshake deadline only.
Socket property after connect sock->timeout TCPTimeout (10 s) Stored on socket; used when applying I/O defaults.
Connect retry sleep Proxy → server proxyconfig loop CONFIG_PROXYCONFIG_RETRY (120 s) Between attempts if server unreachable.
Send config request Proxy → server zbx_get_data_from_server() → send TrapperTimeout Small JSON request.
Receive full config Server → proxy zbx_get_data_from_server() → recv TrapperTimeout, ZBX_TCP_LARGE Large compressed config (can be 100+ MB).
Send config body Server → proxy proxyconfig_read.czbx_tcp_send_ext TrapperTimeout Server builds and sends bulk config on same connection.

Typical failure if too low: cannot obtain configuration data from server at "...": read timeout (proxy waiting for large config or server still sending).

Active — history data (datasender.c → server zbx_recv_proxy_data)

Stage Direction Function / location Timeout Notes
Connect + TLS Proxy → server zbx_connect_to_server() Timeout (connect), TCPTimeout (socket) Same as config.
Send proxy data Proxy → server zbx_put_data_to_server() → send TrapperTimeout Often 10–15 MB compressed per batch.
Receive full message Server → trapper process_trapper_child()zbx_tcp_recv_ext TCPTimeout, ZBX_TCP_LARGE Entire JSON message must arrive within this window.
Process history Server (internal) zbx_process_data_from_proxy() (no socket timeout) Can exceed TCPTimeout if many values; proxy already finished send.
Send ACK Server → proxy zbx_send_proxy_data_response() → send TCPTimeout Small JSON response.
Receive ACK Proxy → server zbx_put_data_to_server()zbx_recv_response TrapperTimeout Proxy waits here while server processes; must be ≥ processing time.

Typical failure if too low: cannot send proxy data to server at "...": read timeout (proxy sent data, server still processing before ACK).

Scheduling: DataSenderFrequency controls how often a new connection is attempted, not how long one transfer may take.


Passive proxy (server initiates connection)

sequenceDiagram
    participant PP as Server proxypoller
    participant PT as Proxy trapper

    Note over PP,PT: Configuration push
    PP->>PT: TCP connect (TCPTimeout)
    PP->>PT: TLS accept (connect deadline)
    PP->>PT: Send config request (TrapperTimeout)
    PT->>PP: Metadata JSON (TCPTimeout)
    PP->>PP: Build config (server CPU)
    PP->>PT: Send bulk config (TrapperTimeout)
    PT->>PT: Apply config
    PT->>PP: ACK (TrapperTimeout)

    Note over PP,PT: Proxy data pull
    PP->>PT: TCP connect (TCPTimeout)
    PP->>PT: Send proxy data request (TrapperTimeout)
    Note over PT: Build history JSON (can be slow)
    PT->>PP: Send bulk data (TrapperTimeout)
    PP->>PP: Process data
    PP->>PT: ACK (TCPTimeout)

Passive — configuration (proxypoller.czbx_recv_proxyconfig)

Stage Direction Function / location Timeout Notes
Connect + TLS Server → proxy connect_to_proxy()zbx_tcp_connect TCPTimeout Includes TLS handshake on accepted socket path.
I/O default on socket Server → proxy zbx_socket_apply_io_deadlines TCPTimeout Clears stale deadline after connect.
Send config request Server → proxy send_data_to_proxy TrapperTimeout
Receive proxy metadata Proxy → server zbx_tcp_recv_ext TCPTimeout Small JSON (version, session, revision).
Server builds config Server (internal) zbx_proxyconfig_get_data() (no socket) Can take noticeable time before next send.
Send bulk config Server → proxy send_data_to_proxy TrapperTimeout Large payload.
Receive config on proxy Server → proxy zbx_recv_proxyconfig → recv TCPTimeout, ZBX_TCP_LARGE Still uses TCPTimeout today — may be tight for very large configs; consider aligning with TrapperTimeout.
Send ACK Proxy → server zbx_send_proxy_response TCPTimeout
Receive ACK Server → proxy zbx_recv_response TrapperTimeout After proxy applies config.

Typical failure if too low: cannot send configuration data to proxy "...": read timeout or proxy cannot receive proxy configuration data from server: read timeout.

Scheduling: ProxyConfigFrequency on server drives proxypoller config attempts.

Passive — proxy data (proxypoller.czbx_send_proxy_data)

Stage Direction Function / location Timeout Notes
Connect + TLS Server → proxy connect_to_proxy TCPTimeout
Send proxy data request Server → proxy send_data_to_proxy TrapperTimeout Small JSON.
Build history on proxy Proxy (internal) zbx_send_proxy_data() under LOCK_PROXY_HISTORY (no socket) Counts against server's recv deadline — server starts recv immediately after send.
Send bulk data Proxy → server send_data_to_server TrapperTimeout
Receive bulk data Server → proxy recv_data_from_proxy TrapperTimeout, ZBX_TCP_LARGE
Send ACK Server → proxy zbx_send_proxy_data_response TCPTimeout Small response.
Receive ACK Proxy → server send_data_to_serverzbx_recv_response TrapperTimeout

Typical failure if too low: cannot obtain data from proxy "...": read timeout(server);cannot send proxy data to server: read timeoutorBroken pipe` (proxy, if server already closed).

Scheduling: ProxyDataFrequency on server.


TLS / async TCP notes (Glaber)

After the non-blocking TCP/TLS stack changes:

  • TLS client (SSL_connect): retried with poll until handshake completes or deadline expires.
  • TLS server (SSL_accept): must use the same non-blocking retry loop (required for PSK on passive trapper accept).
  • SSL_write / SSL_read: retried on WANT_READ / WANT_WRITE until complete or deadline.

Broken pipe on SSL_write usually means the peer already closed the connection (often after a read timeout on the other side), not a PSK failure by itself.


Quick tuning guide

Symptom Likely stage Parameter to increase
cannot obtain data from proxy: read timeout Passive: server recv bulk data TrapperTimeout
cannot send proxy data to server: read timeout Active: proxy waiting for server ACK after upload TrapperTimeout
cannot obtain configuration data from server: read timeout Active: proxy recv config TrapperTimeout
cannot send configuration data to proxy: read timeout Passive: server recv ACK after huge config push TrapperTimeout
cannot receive proxy configuration data from server: read timeout Passive: proxy recv config on trapper TCPTimeout (or code change to TrapperTimeout)
cannot connect to proxy / TLS errors during connect Connect/handshake TCPTimeout (and network/firewall)
Slow connect only Connect phase Timeout (active proxy zbx_connect_to_server connect_timeout)

Recommended starting point for large environments

# glaber_server.conf and glaber_proxy.conf
Timeout=4
TCPTimeout=10
TrapperTimeout=300

Increase TrapperTimeout if you routinely transfer very large config snapshots or history batches (> several minutes of server/proxy processing per connection).


Area Main files
Passive poller src/zabbix_server/proxypoller/proxypoller.c
Active proxy → server src/zabbix_proxy/datasender/datasender.c, src/zabbix_proxy/proxyconfig/proxyconfig.c
Passive proxy trapper src/zabbix_server/trapper/proxydata.c, src/zabbix_proxy/proxyconfigwrite/proxyconfig_write.c
Active proxy on server src/zabbix_server/trapper/trapper.c, src/zabbix_server/trapper/trapper_server.c, src/zabbix_server/proxyconfigread/proxyconfig_read.c
Shared helpers src/libs/zbxcommshigh/commshigh.c, src/libs/zbxcomms/comms.c, src/libs/zbxcomms/tls.c
Defaults / config parsing src/zabbix_server/server.c, src/zabbix_proxy/proxy.c

Changelog (Glaber fixes referenced in this doc)

Recent timeout-related fixes in this tree:

  • Passive proxypoller: bulk send/recv uses TrapperTimeout + ZBX_TCP_LARGE for proxy data.
  • Passive proxy trapper (zbx_send_proxy_data): bulk send and ACK recv use TrapperTimeout.
  • Active proxy (datasender, proxyconfig): bulk send/recv to/from server uses TrapperTimeout.
  • Server → active proxy config push (proxyconfig_read.c): bulk send uses TrapperTimeout.
  • TLS accept: non-blocking SSL_accept retry loop aligned with SSL_connect.