Skip to content

Getting started

Connecting

How SyncVerseMaster connects, and how to read the reason when a connection is refused.

Connect from settings

master.Connect() with no arguments reads the SyncVerseSettings asset. In Cloud mode it connects to the cloud URL with your App ID; in Self-hosted mode it connects to the server URL.

C#
// Self-hosted: pass the server URL (ws:// locally, wss:// behind TLS).
master.Connect ("ws://localhost:9000");

// Cloud without a settings asset:
master.ConnectCloud ("sv_app_xxxxxxxxxxxxxxxxxxxx");

Events

C#
master.OnConnected += () => Debug.Log ($"Connected, region {master.Region}");
master.OnConnectRejected += (code, message) => {
    // Typed reason from the server, e.g. InvalidAppId, QuotaExceeded, TokenRequired.
    Debug.LogWarning ($"Refused: {code} ({message})");
};
master.OnConnectFailed += reason => Debug.LogError (reason); // every failure, readable text
master.OnDisconnected += () => Debug.Log ("Lobby connection closed");
master.Connect ();

OnConnected fires after the server's welcome, once the protocol versions match. When a connection is refused, OnConnectRejected fires with a ConnectErrorCode, then OnConnectFailed with readable text. master.LastError keeps the last refusal.

Why a connection was refused

The server refuses before a WebSocket opens, with an HTTP error. Browsers and the Unity transport cannot read that status, so after a failed handshake the SDK makes one request to the server's /check endpoint, which answers the same question without opening a socket. Successful connections never make that request.

CodeHTTPMeaningWhat to do
InvalidAppId401Missing or unknown App IDCopy the App ID from the dashboard
TokenRequired401The project requires access tokensSend a token
InvalidToken401Bad signature, revoked key or expired tokenMint a fresh token
QuotaExceeded429The project is at its concurrent-connection limitWait for players to leave, or raise the limit
OriginNotAllowed403A WebGL build on a site not in allowed originsAdd the site in Settings
ProjectPaused403Paused after 90 days without connectionsReactivate it in the dashboard
RateLimited429Too many connection attempts from one addressBack off and retry
ProtocolMismatch426SDK and server speak different protocol versionsUpdate the SDK
ServiceUnavailable503No capacity right now, or the node is fullRetry; a new room lands elsewhere
InvalidTicket401Room ticket missing, expired or for another roomFetch the room again for a fresh ticket
RoomNotFound404The room is gone (self-hosted)Create or find another room

Regions

SyncVerse Cloud runs in one region today, the EU. The welcome message names it and the SDK exposes it as master.Region. More regions are planned; the Region setting stays auto until then.

WebGL

WebGL builds connect over wss:// like any other platform. If your project lists allowed origins, the page hosting the build must be one of them. Native builds send no origin and are not affected.