Skip to main content

Overview

The III SDK automatically reconnects when the WebSocket connection drops, using exponential backoff with jitter to prevent thundering herd problems. All functions, triggers, and services are automatically re-registered after reconnection.

Default Behavior

By default, the SDK reconnects indefinitely with these settings:

Reconnection Algorithm

The SDK calculates retry delays using exponential backoff with jitter:
Example retry sequence (with defaults):
  • Attempt 1: ~1s (1000ms ± 300ms)
  • Attempt 2: ~2s (2000ms ± 600ms)
  • Attempt 3: ~4s (4000ms ± 1200ms)
  • Attempt 4: ~8s (8000ms ± 2400ms)
  • Attempt 5: ~16s (16000ms ± 4800ms)
  • Attempt 6+: ~30s (30000ms ± 9000ms) - capped

Custom Configuration

Basic Configuration

OpenTelemetry Connection Reconnection

The OpenTelemetry telemetry system uses a separate WebSocket connection for traces, metrics, and logs. You can configure its reconnection independently:

Connection State Monitoring

1

Track connection state

Monitor the connection lifecycle to implement custom logic:
2

Query current state

Check the current connection state synchronously:

Automatic Re-registration

When the connection is re-established, the SDK automatically re-registers:
  • All registered functions (local and HTTP)
  • All registered trigger types
  • All registered triggers
  • All registered services
  • Pending invocation messages (queued while disconnected)

Invocation Behavior During Reconnection

Queuing Messages

Messages sent while disconnected are queued (up to 1000 messages) and sent when the connection is restored:

Timeout Behavior

Invocations with await that were sent before disconnect will timeout normally:

Configuration Examples

Development (Fast Retries)

Production (Resilient)

Ephemeral Workers (No Retries)

Debugging Reconnection

Best Practices

Reconnection Strategy Checklist:
  • ✅ Use infinite retries (maxRetries: -1) in production
  • ✅ Monitor connection state for critical paths
  • ✅ Use jitter (jitterFactor > 0) to prevent thundering herd
  • ✅ Set reasonable maxDelayMs (30-60s) to balance responsiveness and load
  • ✅ Configure telemetry reconnection separately (less critical than functions)
  • ✅ Test failure scenarios (network partitions, engine restarts)
  • ✅ Implement alerting when state reaches 'failed'