Skip to main content
New protocol version released: This page may contain outdated information.
The HAIP SDK supports multiple transport protocols for different environments and use cases. Each transport implements the same interface but uses different underlying communication mechanisms.

Transport Types

WebSocket Transport

The default and most feature-complete transport, supporting real-time bidirectional communication. Features:
  • Real-time bidirectional communication
  • Binary data support
  • Automatic reconnection
  • Flow control
  • Heartbeat monitoring
Usage:
Configuration Options:
url
string
required
WebSocket server URL (ws:// or wss://).
token
string
required
JWT authentication token.
options
WebSocketTransportOptions
Additional WebSocket-specific options.

Server-Sent Events (SSE) Transport

Browser-only transport using Server-Sent Events for receiving data and HTTP POST for sending. Features:
  • Browser-native support
  • Automatic reconnection
  • HTTP POST for sending messages
  • Event stream parsing
Usage:
Configuration Options:
url
string
required
SSE endpoint URL (http:// or https://).
token
string
required
JWT authentication token.
options
SSETransportOptions
Additional SSE-specific options.
Limitations:
  • Browser environment only
  • No binary data support
  • Unidirectional for receiving (uses HTTP POST for sending)

HTTP Streaming Transport

Universal transport using fetch streaming for both sending and receiving. Features:
  • Works in Node.js and browsers
  • Fetch-based streaming
  • Automatic reconnection
  • Universal compatibility
Usage:
Configuration Options:
url
string
required
HTTP streaming endpoint URL.
token
string
required
JWT authentication token.
options
HTTPStreamingTransportOptions
Additional HTTP streaming options.

Transport Comparison

FeatureWebSocketSSEHTTP Streaming
EnvironmentNode.js + BrowserBrowser onlyNode.js + Browser
Bidirectional❌ (POST for sending)
Binary Support
Real-time
Reconnection
Flow Control
Heartbeat
PerformanceExcellentGoodGood
CompatibilityHighMediumHigh

Transport Selection

Choose WebSocket when:

  • You need full bidirectional communication
  • Binary data support is required
  • Maximum performance is needed
  • Both Node.js and browser environments

Choose SSE when:

  • Browser-only application
  • Server-sent events are preferred
  • Simpler server implementation
  • Real-time updates are the primary need

Choose HTTP Streaming when:

  • Universal compatibility is required
  • Fetch API is preferred
  • Both Node.js and browser support needed
  • Simpler deployment (no WebSocket server)

Transport Configuration

Global Configuration

Transport-Specific Configuration

Connection Management

Automatic Reconnection

All transports support automatic reconnection with exponential backoff:

Manual Reconnection

Transport Events

All transports emit the same events:

Transport Health Monitoring

Connection State

Performance Metrics

Transport Switching

You can switch transports by creating a new client:

Transport Testing

Testing Different Transports

Next Steps

Client API

Learn about the client interface and methods.

Examples

See practical examples of transport usage.

Authentication

Understand authentication across different transports.

API Reference

Full API reference documentation.