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.
// 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
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.
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
InvalidAppId | 401 | Missing or unknown App ID | Copy the App ID from the dashboard |
TokenRequired | 401 | The project requires access tokens | Send a token |
InvalidToken | 401 | Bad signature, revoked key or expired token | Mint a fresh token |
QuotaExceeded | 429 | The project is at its concurrent-connection limit | Wait for players to leave, or raise the limit |
OriginNotAllowed | 403 | A WebGL build on a site not in allowed origins | Add the site in Settings |
ProjectPaused | 403 | Paused after 90 days without connections | Reactivate it in the dashboard |
RateLimited | 429 | Too many connection attempts from one address | Back off and retry |
ProtocolMismatch | 426 | SDK and server speak different protocol versions | Update the SDK |
ServiceUnavailable | 503 | No capacity right now, or the node is full | Retry; a new room lands elsewhere |
InvalidTicket | 401 | Room ticket missing, expired or for another room | Fetch the room again for a fresh ticket |
RoomNotFound | 404 | The 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.