我们刚刚将SyncGatewaty升级到2.1。因此,现在我将客户代码重构为使用CouchbaseLite 2.1。当我尝试复制时,出现错误:
Got LiteCore错误:未找到(6/404)
最初连接到Dev Server时出现错误,然后在笔记本电脑上安装了本地clean
副本,尝试连接时也遇到了相同的错误。
日志:
INFO)Couchbase 2019-01-10T10:56:47.8503147-07:00(启动)[1] CouchbaseLite / 2.1.2(.NET; Microsoft Windows 10.0.17763)Build / 13 LiteCore /(15)提交/ 9aebf28
警告)LiteCore 2019-01-10T10:56:48.1943139-07:00 {C4SocketImpl#1} ==>类litecore :: repl :: C4SocketImpl ws://localhost.com:443 // _ blipsync
警告)LiteCore 2019-01-10T10:56:48.1943139-07:00 {C4SocketImpl#1}意外或不干净的套接字断开连接! (原因= WebSocket状态,代码= 404)
错误)同步2019-01-10T10:56:48.1993137-07:00 {Repl#2} ==>类litecore :: repl ::复制器c:\ temp \ content_meta_data.cblite2 \-> ws://本地主机:443 // _ blipsync
错误)同步2019-01-10T10:56:48.1993137-0 7:00 {Repl#2}出现LiteCore错误:未找到(6/404)
我的代码:
using System;
using System.IO;
using Couchbase.Lite;
using Couchbase.Lite.Support;
using Couchbase.Lite.Sync;
using NLog;
namespace ReplicatorExample
{
public class DatabaseManager
{
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
public const string BUCKET_CONTENT_META_DATA = "content_meta_data";
private static DatabaseManager _instance;
public static DatabaseManager GetInstance()
{
NetDesktop.Activate();
NetDesktop.EnableTextLogging("logs");
return _instance ?? (_instance = new DatabaseManager());
}
public void InitializeBuckets()
{
try
{
var defaultAuthenticator = GetDefaultAuthenticator();
var dirInfo = new DirectoryInfo($"c:\\temp\\{BUCKET_CONTENT_META_DATA}");
if (!dirInfo.Parent.Exists)
{
dirInfo.Parent.Create();
}
var database = new Database(dirInfo.FullName);
// Create replicator to push and pull changes to and from the cloud
var targetEndpoint = new URLEndpoint(new Uri("ws://localhost:4985"));
var replConfig = new ReplicatorConfiguration(database, targetEndpoint)
{
Authenticator = defaultAuthenticator,
Continuous = true,
//Channels = new List<string>
//{
// "approved",
//
//}
};
var replicator = new Replicator(replConfig);
replicator.AddChangeListener((sender, args) =>
{
if (args.Status.Error != null)
{
_log.Error($"{args.Status.Error}");
}
else
{
_log.Debug(args.Status);
}
});
replicator.Start();
}
catch (Exception e)
{
_log.Error(e);
}
}
private Authenticator GetDefaultAuthenticator()
{
return new BasicAuthenticator("BigD","123456");
}
}
}
答案 0 :(得分:1)
我相信您需要在targetEndpoint
的URL中指定数据库名称。
例如:var targetEndpoint = new URLEndpoint(new Uri("ws://localhost:4984/mydatabase"));