Table of Contents

Method ConnectAsync

Namespace
OBSStudioClient.Model
Assembly
OBSClient.dll

ConnectAsync(string, int, string, CancellationToken)

Connects to OBS Studio, and reads its scenes, inputs and scene items. The task completes when the model is complete.

public Task ConnectAsync(string hostname = "localhost", int port = 4455, string password = "", CancellationToken cancellationToken = default)

Parameters

hostname string

The name or address of the computer that OBS Studio runs on.

port int

The port of the WebSocket server of OBS Studio.

password string

The password of the WebSocket server, or empty when it has none.

cancellationToken CancellationToken

A token that ends the attempt.

Returns

Task

Remarks

When it fails, nothing is left connected, and nothing keeps trying. After it succeeds, the connection is restored when it is lost (AutoReconnect), and the model is read again.

Exceptions

InvalidOperationException

The model is connected or connecting already.

ObjectDisposedException

The ObsModel is disposed.

ObsNotConnectedException

OBS Studio could not be reached, refused the password, or the connection ended before the model was complete.

ObsVersionNotSupportedException

OBS Studio is older than 30.1.

TimeoutException

The model was not complete within SynchronizationTimeout.

OperationCanceledException

cancellationToken was cancelled, or DisconnectAsync() was called, or the ObsModel was disposed, while it was connecting.