Couchbase.Lite无法复制

问题描述 投票:0回答:1

我正在尝试通过C#Couchbase.Lite库复制Couchbase Enterprise数据库。通过SSH隧道访问同步网关。即使我按照文档中的说明使用它,复制也无法正常进行。

这些是Couchbase Lite日志:

2020-2-6 02:05:21.032+01:00 [1]| INFO)  [Database] (Startup) [1] CouchbaseLite/2.7.0 (.NET; Microsoft Windows 10.0.18363 ) Build/109 LiteCore/2.7.0 (157) Commit/7031539e
2020-2-6 02:05:21.042+01:00 [1]| WARNING)  [Database] (Logging) [1] Database.Log.File.Config is null, meaning file logging is disabled.  Log files required for product support are not being generated.
Database replicator activity changed to Connecting
Invalid URI: The hostname could not be parsed.
2020-2-6 02:05:36.091+01:00 [10]| ERROR)  [Network] {C4SocketImpl#1}==> class litecore::repl::C4SocketImpl ws://localhost:4984/fieldforce/_blipsync @00000245EA1BCB50
2020-2-6 02:05:36.091+01:00 [10]| ERROR)  [Network] {C4SocketImpl#1} No response received after 15 sec -- disconnecting
2020-2-6 02:05:36.093+01:00 [12]| WARNING)  [Network] {C4SocketImpl#1} Unexpected or unclean socket disconnect! (reason=Network error, code=3)
2020-2-6 02:05:36.096+01:00 [4]| ERROR)  [Replicator] {Repl#2}==> class litecore::repl::Replicator D:\Repos\ReplicatorTest\ConsoleApp1\bin\Debug\netcoreapp2.2\CouchbaseLite\fieldforce.cblite2\ ->ws://loc
alhost:4984/fieldforce/_blipsync @00000245EA1BC6D8
2020-2-6 02:05:36.096+01:00 [4]| ERROR)  [Replicator] {Repl#2} Got LiteCore error: Network error 3 "connection timed out"
Database replicator activity changed to Connecting; last exception: Couchbase.Lite.CouchbaseNetworkException: CouchbaseLiteException (NetworkDomain / 3): connection timed out.
Database replicator activity changed to Offline; last exception: Couchbase.Lite.CouchbaseNetworkException: CouchbaseLiteException (NetworkDomain / 3): connection timed out.
Database replicator activity changed to Connecting
Invalid URI: The hostname could not be parsed.
2020-2-6 02:05:53.107+01:00 [10]| ERROR)  [Network] {C4SocketImpl#3}==> class litecore::repl::C4SocketImpl ws://localhost:4984/fieldforce/_blipsync @00000245EA771EC0
2020-2-6 02:05:53.107+01:00 [10]| ERROR)  [Network] {C4SocketImpl#3} No response received after 15 sec -- disconnecting
2020-2-6 02:05:53.108+01:00 [20]| WARNING)  [Network] {C4SocketImpl#3} Unexpected or unclean socket disconnect! (reason=Network error, code=3)
2020-2-6 02:05:53.108+01:00 [21]| ERROR)  [Replicator] {Repl#4}==> class litecore::repl::Replicator D:\Repos\ReplicatorTest\ConsoleApp1\bin\Debug\netcoreapp2.2\CouchbaseLite\fieldforce.cblite2\ ->ws://lo
calhost:4984/fieldforce/_blipsync @00000245EA1BC2C8
2020-2-6 02:05:53.108+01:00 [21]| ERROR)  [Replicator] {Repl#4} Got LiteCore error: Network error 3 "connection timed out"
Database replicator activity changed to Connecting; last exception: Couchbase.Lite.CouchbaseNetworkException: CouchbaseLiteException (NetworkDomain / 3): connection timed out.
Database replicator activity changed to Offline; last exception: Couchbase.Lite.CouchbaseNetworkException: CouchbaseLiteException (NetworkDomain / 3): connection timed out.

这是C#代码:

var database = new Database("foo");

var targetUri = new Uri("ws://localhost:4984/foo");
var gateway = new URLEndpoint(targetUri);
var replicationConfig = new ReplicatorConfiguration(database, gateway)
{
    ReplicatorType = ReplicatorType.PushAndPull,
    Authenticator = new BasicAuthenticator("user", "password")
};

var replicator = new Replicator(replicationConfig);
replicator.AddChangeListener((sender, args) =>
{
    var activity = args.Status.Activity;
    var error = args.Status.Error;

    if (error == null)
    {
        Console.WriteLine($"Database replicator activity changed to {activity}");
    }
    else
    {
        Console.WriteLine($"Database replicator activity changed to {activity}; last exception: {error}");
    }
});
replicator.Start();
c# couchbase-lite couchbase-sync-gateway
1个回答
1
投票

如日志中所示,Couchbase Lite客户端无法访问Sync Gateway。确认可以从尝试复制的设备通过网络访问Sync Gateway。

[您还提到了“通过SSH隧道到达Sync Gateway”-没有理由您只应通过SSH隧道访问Sync Gateway。因此,请确保您的同步网关的公共端口可直接访问。复制通过已认证的公共端口进行。但是,建议不要将管理端口直接暴露给外部网络。

© www.soinside.com 2019 - 2024. All rights reserved.