EdgeStream
Transport Overview
EdgeStream supports four transports: SignalR, WebSocket, SSE, and HTTP Polling. Each wraps the same ITransport interface so the pipeline above is identical regardless of the wire protocol underneath.
The Four Transports
| Transport | Type | Direction | Reconnect | Best For |
|---|---|---|---|---|
'signalr' | SignalRTransport | Bidirectional | Automatic (exponential) | Browser apps on ASP.NET backends |
'websocket' | RawWebSocketTransport | Bidirectional | Automatic (exponential) | Mobile, server-to-server, non-ASP.NET |
'sse' | SseTransport | Server → Client only | Automatic (exponential) | Read-only dashboards, notification streams |
'http-polling' | HttpPollingTransport | Bidirectional | Adaptive backoff | Firewalled environments, legacy proxies |
Default Recommendation
For BizFirstGO browser applications connecting to ASP.NET Core SignalR hubs, use 'signalr'. It handles WebSocket, SSE, and long-polling fallback internally so you do not need to configure fallbacks manually:
stream.registerServer({
id: 'bas',
type: 'bas',
url: '/hubs/edge-stream',
transportConfig: {
type: 'signalr',
url: '/hubs/edge-stream',
accessToken: () => authStore.getToken(),
}
});
ITransport Interface
Every transport implements the same interface. This is how EdgeStream remains transport-agnostic:
interface ITransport {
readonly id: string;
readonly type: 'signalr' | 'websocket' | 'sse' | 'http-polling';
readonly status: TransportStatus; // 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error'
readonly lastError?: Error;
connect(): Promise<void>;
disconnect(): Promise<void>;
send(data: string | ArrayBuffer): Promise<void>;
onMessage(handler: (raw: string | ArrayBuffer) => void): () => void;
onStatusChange(handler: (status: TransportStatus) => void): () => void;
onError(handler: (error: Error) => void): () => void;
}
Auto-Detection
createAutoTransport() picks the best available transport for the current environment:
import { createAutoTransport, detectBestTransport } from 'edge-stream-js';
// Detect without creating
const type = detectBestTransport();
// 'websocket' if WebSocket supported, 'sse' if EventSource supported, 'http-polling' fallback
// Create with auto-detection
const transport = createAutoTransport('wss://example.com/ws');
// Create with preferred type (falls back if unavailable)
const preferred = createAutoTransport('wss://example.com/ws', 'websocket');
Transport Status Values
| Status | Meaning |
|---|---|
'disconnected' | Not connected — initial state or after explicit disconnect |
'connecting' | Connection attempt in progress |
'connected' | Ready to send and receive messages |
'reconnecting' | Lost connection, attempting automatic reconnect |
'error' | Unrecoverable error — manual reconnect required |
Transport vs Server
A transport handles the wire protocol. A server owns a transport and manages the message pipeline. You configure the transport via
transportConfig when registering the server — you do not create transports directly.