Reputation: 916
I am trying to replicate a Couchbase Enterprise DB via the C# Couchbase.Lite library. The sync gateway is accessed via an SSH tunnel. Even though am I using it as described in the documentation the replication does not work.
These are the Couchbase Lite logs:
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.
This is the C# code:
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();
Upvotes: 0
Views: 898
Reputation: 1443
As indicated in the logs, the Couchbase Lite client is unable to reach the Sync Gateway. Confirm that the Sync Gateway is accessible over the network from the device from where the replication is attempted.
Also you mention "SSH tunneling to get to Sync Gateway "- there is no reason you should have your Sync Gateway accessible only over a SSH tunnel. So make sure that your sync gateway's public port is accessible directly. Replication happens over public port which is authenticated. It is however recommended that the admin port never be directly exposed to the external network.
Upvotes: 1