{"record":{"id":"cb33f6f50ce96891","repo":"tursodatabase/turso","slug":"sync-interval-requires-an-embedded-replica-connect","errorCode":null,"errorMessage":"Sync Interval requires an embedded replica connection.","messagePattern":"Sync Interval requires an embedded replica connection\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoConnection.cs","lineNumber":468,"sourceCode":"        {\n            remoteClient.CloseAsync(DefaultTimeout, CancellationToken.None).GetAwaiter().GetResult();\n        }\n        catch\n        {\n            InvalidateRemoteSession();\n        }\n    }\n\n    private void OpenRemote()\n    {\n        if (_connectionOptions.IsReplica)\n        {\n            OpenReplica();\n            return;\n        }\n\n        if (_connectionOptions.SyncInterval > 0)\n            throw new NotSupportedException(\"Sync Interval requires an embedded replica connection.\");\n        if (_connectionOptions.HasAdvancedReplicaOptions)\n            throw new NotSupportedException(\"Advanced sync options require an embedded replica connection.\");\n\n        if (_connectionOptions.GetEncryptionCipher().HasValue || !string.IsNullOrWhiteSpace(_connectionOptions[\"Encryption Key\"]))\n            throw new InvalidOperationException(\"Encryption Cipher and Encryption Key are local database options and cannot be used with remote Turso URLs.\");\n\n        var handler = RemoteMessageHandlerFactory?.Invoke();\n        _remoteClient = handler is null\n            ? new TursoRemoteClient(_connectionOptions.GetRemoteUri(), _connectionOptions.AuthToken)\n            : new TursoRemoteClient(\n                new HttpClient(handler),\n                _connectionOptions.GetRemoteUri(),\n                _connectionOptions.AuthToken,\n                disposeHttpClient: true);\n    }\n\n    private void OpenReplica()\n    {","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/tursodatabase/turso/blob/6c7252267988c76e632af00a671e4b9788dfae13/bindings/dotnet/src/Turso.Data/TursoConnection.cs#L450-L486","documentation":"SyncInterval is a replica-only option: it schedules periodic background syncs of an embedded replica. OpenRemote detects a remote Turso URL and checks replica options; setting SyncInterval > 0 on a plain remote (non-replica) connection is a configuration contradiction, so Open throws NotSupportedException.","triggerScenarios":"Opening a TursoConnection whose connection string is a remote turso:// URL (OpenRemote path) while SyncInterval=... is present in the connection string/options.","commonSituations":"Copying a replica connection string and swapping only the URL to a remote one, misunderstanding that SyncInterval works with pure remote connections, migrating from embedded replica to remote-only and leaving the option behind.","solutions":["Remove SyncInterval from the connection string if you want a plain remote connection.","Switch to an embedded-replica connection string (local file path + remote URL) to keep periodic syncs.","Call Sync/SyncAsync manually on demand instead of using the interval option."],"exampleFix":"// before\nvar cs = \"Data Source=turso://mydb-myorg.turso.io;SyncInterval=60;\";\n// after\nvar cs = \"Data Source=/local/replica.db;Uri=turso://mydb-myorg.turso.io;SyncInterval=60;\";","handlingStrategy":"validation","validationCode":"var b = new DbConnectionStringBuilder { ConnectionString = cs };\nbool isRemote = (b.ContainsKey(\"Data Source\") && (b[\"Data Source\"] as string ?? \"\").StartsWith(\"turso://\"));\nif (isRemote && b.ContainsKey(\"SyncInterval\")) throw new NotSupportedException(\"SyncInterval needs an embedded replica\");","typeGuard":null,"tryCatchPattern":"try { conn.Open(); } catch (NotSupportedException ex) when (ex.Message.Contains(\"Sync Interval\")) { /* strip SyncInterval or switch to replica connection string */ }","preventionTips":["Build connection strings from option objects, not string concatenation.","Separate remote vs replica connection factories in your codebase.","Validate options against connection type before Open."],"tags":["dotnet","embedded-replica","connection-string","configuration"],"backgroundTag":"invalid-connection-string-option","analyzedSha":"6c7252267988c76e632af00a671e4b9788dfae13","analyzedAt":"2026-08-31T11:17:35.598Z","contentChangedAt":"2026-08-31T11:17:35.598Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}