I have an app that works on Xam.Mac and iOS, but SG and CBL are not supported there. Upgrading my mac to Ventura caused the Mac app to stop working. I could never get it going again (after several weeks of effort).
So I’m working on upgrading my app to .Net 6 or 7. First step was to create a test application - a simple default “Mac OS .Net App”. That runs fine. Then I added the CBL nuget package and libLiteCore native reference. Then the only code I added was to open a DB, check it works, and start a sync (I’ll paste the code below).
Open/Write/Read to the database works, but the sync fails with the following errors:
The type initializer for 'Couchbase.Lite.Support.MacProxy' threw an exception.
2023-1-26 10:09:39.521+13:00 [3]| ERROR) [Network] {C4SocketImpl#15} No response received after 15 sec -- disconnecting
...
2023-1-26 10:09:39.524+13:00 [24]| ERROR) [Replicator] {Repl#14} Got LiteCore error: Network error 3, "connection timed out"
I’ve turned the logging up on the sync server, and no connection comes in (i.e. no messages). I’ve tried a sync server running remotely and locally:
2023-1-26 10:09:39.525+13:00 [24]| INFO) [Replicator] (Replicator) [24] Replicator[<*> ws://localhost:4984/testdb] is Connecting, progress 0/0
Same results either way. I’ve also tried this using .Net6 and .Net7 and over TLS.
I know the sync server does work because prior to the Ventura upgrade, everything was fine. Also, the iOS app on my phone still connects and syncs and works.
Does anyone have an idea as to how I can troubleshoot this? Or what might have gone wrong after the Ventura upgrade? Why is that simple program generating an exception in MacProxy (BTW - I think that MacProxy has some bad paths - see here)
Many thanks.
Paul.
Below is a copy of the code that was added to the ViewController.ViewDidLoad
DatabaseConfiguration options = null;
Database database = null;
Replicator replicator = null;
public void DoTest()
{
try
{
Database.Log.Console.Domains = LogDomain.All;
Database.Log.Console.Level = LogLevel.Verbose;
options = new DatabaseConfiguration
{
Directory = "."
};
database = new Database("MyTest", options);
Console.WriteLine("Database opened ok");
}
catch (Exception e)
{
Console.WriteLine("Failed to open database: " + e.Message);
return;
}
// Prove the database works by saving and loading a document.
var id = System.Guid.NewGuid().ToString();
var doc = new MutableDocument(id);
doc.SetBoolean("b", true);
doc.SetInt("i", 1024);
database.Save(doc);
var newdoc = database.GetDocument(id);
if (newdoc is null)
{
Console.WriteLine("Failed to write/read from the database");
return;
}
// Lets start the sync engine.
try
{
var url = new Uri("ws://localhost:4984/testdb");
var target = new URLEndpoint(url);
var auth = new BasicAuthenticator("8afA2PdF8qYS", "the-password");
var sync_config = new ReplicatorConfiguration(database, target)
{
ReplicatorType = ReplicatorType.PushAndPull,
Continuous = true,
Authenticator = auth,
ConflictResolver = null,
};
replicator = new Replicator(sync_config);
var listenerToken = replicator.AddChangeListener(SyncStatusUpdate);
Console.WriteLine("StartSyncAgent: Using url: " + url);
replicator.Start();
Console.WriteLine("Completed startup");
}
catch (Exception e)
{
Console.WriteLine("Got exception");
}
}
public void SyncStatusUpdate(object? sender, ReplicatorStatusChangedEventArgs e)
{
var changes = (int)e.Status.Progress.Total;
var completed = (int)e.Status.Progress.Completed;
Console.WriteLine("SyncStatusUpdate for changes {0}, completed {1}, status {2}",
changes, completed, e?.Status.Activity);
if (e?.Status.Error != null)
{
Console.WriteLine($"Error :: {e?.Status.Error}");
}
}