Skip to main content
Unsupported HAIP 1 archive. This is historical chat and streaming documentation, not the HAIP 2 review protocol. Its APIs, package examples and security advice must not be used for a HAIP 2 deployment. Start with the current HAIP 2 guides.

Overview

HAIP implements credit-based flow control to prevent overwhelming systems with messages and ensure reliable communication. Flow control operates on a per-channel basis, allowing fine-grained control over different types of traffic.

Flow Control Basics

Credit System

Flow control uses a credit-based system where each channel has:
  • Message credit: Number of messages that can be sent
  • Byte credit: Number of bytes that can be sent

Initial Credit

Initial credit is advertised during the handshake:

Flow Control Implementation

Client-Side Flow Control

Server-Side Flow Control

Flow Control Events

FLOW_UPDATE

Grant additional credit to a channel:

PAUSE_CHANNEL

Immediately pause a channel:

RESUME_CHANNEL

Resume a paused channel:

Adaptive Flow Control

Dynamic Credit Adjustment

Back-Pressure Detection

Channel-Specific Flow Control

Audio Channel Management

Text Channel Management

Monitoring and Metrics

Flow Control Metrics

Best Practices

Monitor Queues

Regularly check message queue lengths and processing times to detect back-pressure early.

Adaptive Credits

Adjust credit grants based on system performance and queue lengths.

Channel Isolation

Use separate channels for different types of traffic to prevent one from affecting others.

Graceful Degradation

When under pressure, gracefully reduce functionality rather than failing completely.