问题
Getting below error while connecting CouchDB server using Replicator
Status{activityLevel=CONNECTING,
progress=Progress{completed=0, total=0},
error=CouchbaseLiteException{CouchbaseLite,11001,'WebSocket connection closed by peer'}}
Status{activityLevel=STOPPED,
progress=Progress{completed=0, total=0},
error=CouchbaseLiteException{CouchbaseLite,11001,'WebSocket connection closed by peer'}}
Below is my code;
Replicator replicator = null;
try {
CouchbaseLite.init(context);
Database.setLogLevel(LogDomain.ALL, LogLevel.ERROR);
DatabaseConfiguration databaseConfiguration = new DatabaseConfiguration();
Database database = new Database("company-3", databaseConfiguration);
URLEndpoint target = new URLEndpoint(new URI("ws://*****/company-3/"));
ReplicatorConfiguration config = new ReplicatorConfiguration(database, target);
config.setAuthenticator(new BasicAuthenticator("username", "password"));
replicator = new Replicator(config);
replicator.start();
} catch (CouchbaseLiteException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
Dependancy:
implementation 'com.couchbase.lite:couchbase-lite-android:2.7.0'
来源:https://stackoverflow.com/questions/59945185/how-to-resolve-connection-error-in-couchdb-android