Portal Community

Configuration

stream.registerServer({
  id: 'bas',
  type: 'bas',
  url: '/hubs/edge-stream',
  transportConfig: {
    type: 'signalr',
    url: '/hubs/edge-stream',

    // Auth token (optional) — injected via accessTokenFactory
    accessToken: authStore.getToken(),

    // Custom headers (optional)
    headers: { 'X-Client-Version': '2.0' },

    // Reconnect configuration (optional)
    reconnect: {
      maxAttempts: 0,         // 0 = unlimited
      initialDelayMs: 1000,
      maxDelayMs: 30000,
      backoffMultiplier: 2,
    },
  }
});

Hub Methods

The SignalRTransport uses these hub method names by convention:

DirectionMethodDescription
Inbound (server → client)ReceiveMessageHub calls this when pushing a message to the client
Outbound (client → server)SendMessageClient invokes this to send a message to the hub

How It Works

// Internal implementation (simplified)
class SignalRTransport extends BaseTransport {
  private messageMethodName = 'ReceiveMessage';

  async connect(): Promise<void> {
    const builder = new SignalR.HubConnectionBuilder()
      .withUrl(this.config.url, this.config.accessToken
        ? { accessTokenFactory: () => this.config.accessToken! }
        : {})
      .withAutomaticReconnect(); // exponential backoff built-in

    this.connection = builder.build();

    // Register inbound handler
    this.connection.on('ReceiveMessage', (raw: string | ArrayBuffer) => {
      this.emitMessage(raw); // feeds EdgeStream pipeline
    });

    // Reconnection lifecycle
    this.connection.onreconnecting(() => this.setStatus('reconnecting'));
    this.connection.onreconnected(() => this.setStatus('connected'));
    this.connection.onclose(() => this.setStatus('disconnected'));

    await this.connection.start();
    this.setStatus('connected');
  }

  async send(data: string | ArrayBuffer): Promise<void> {
    const message = typeof data === 'string' ? data : new TextDecoder().decode(new Uint8Array(data));
    await this.connection!.invoke('SendMessage', message);
  }
}

ASP.NET Core Hub Setup

Your hub must handle the matching method names:

// C# — ASP.NET Core SignalR hub (server-side)
public class EdgeStreamHub : Hub
{
    // Client sends → hub receives
    public async Task SendMessage(string message)
    {
        // Process and optionally broadcast back
        await Clients.All.SendAsync("ReceiveMessage", message);
    }
}

Automatic Reconnection

withAutomaticReconnect() is always enabled in SignalRTransport. SignalR manages the reconnect delays internally. The transport emits status events during the cycle:

const server = stream.server('bas')!;

server.transport.onStatusChange((status) => {
  switch (status) {
    case 'reconnecting':
      ui.showBanner('Connection lost — reconnecting...');
      break;
    case 'connected':
      ui.hideBanner();
      break;
    case 'error':
      ui.showError('Connection failed');
      break;
  }
});
Recommended for BizFirstGO Apps SignalR is the recommended transport for all browser-based BizFirstGO clients. It negotiates the best available protocol (WebSocket preferred, SSE fallback, long-polling last resort) without any extra configuration.