Background: I am trying to connection my android app (with couchbase-lite) to sync_gateway. I am running my app straight from android studio. The data gets stored locally in the device but how do I sync it with the sync gateway? This is the code that I have for initiation.
database = manager.getDatabase(dbname);
//TODO: Only if the user is logged in
URL url = new URL("http://10.0.0.6:4984/sync_gateway/");
Replication push = database.createPushReplication(url);
Replication pull = database.createPullReplication(url);
pull.setContinuous(true);
push.setContinuous(true);
// BasicAuthenticator auth = new BasicAuthenticator(USERNAME, PASSWORD);
// push.setAuthenticator(auth);
// pull.setAuthenticator(auth);
push.addChangeListener(new Replication.ChangeListener() {
@Override
public void changed(Replication.ChangeEvent event) {
Toast toast = Toast.makeText(DataService.context, "Push:" + event.getError().getMessage(), Toast.LENGTH_SHORT);
toast.show();
}
});
pull.addChangeListener(new Replication.ChangeListener() {
@Override
public void changed(Replication.ChangeEvent event) {
Toast toast = Toast.makeText(DataService.context, "Pull:" + event.getError().getMessage(), Toast.LENGTH_SHORT);
toast.show();
}
});
push.start();
pull.start();
You can try accessing {{my actual IP}}:4984/sync_gateway/ in the browser of the android device to test the url.
If it’s up, then there’s something with the replication code in the app.
Can you see things happening in the SG logs?
Are exceptions thrown in the Android debugger?
I’m having the same issue with setting up sync gateway on an Amazon EC2 Windows instance. Whenever I attempt to connect to the sync gateway from anywhere other than localhost I get a connection refused error. I have checked that both ports 4984 and 4985 are open both in the Amazon security group as well as in the Windows firewall. The server was started using default settings
sync_gateway -url http://localhost:8091
I do not see any activity or errors on the server when making these requests unless they are made from the local machine using
http://localhost:4984/sync_gateway/
which succesfully returns a JSON response containing information about the server.
If it is relevant, I am making these requests through a web browser as for now I am only interested in whether I have configured everything properly. Any help would be very much appreciated.
If that solves your issue, you can then change the public REST interface IP address to bind to the specific public interface of your AWS instances. You would want to limit access to the admin interface, so you could either bind that to localhost (127.0.0.1) or to the private IP address of your AWS instance.
Hey there, I have recently started working on Couchbase and its feature. I was trying to connect to Sync_Gateway through the URL mentioned got the same kinda issue you stated above. Seems you got the issue quite earlier, did you got the solution?
The command you show above binds the interfaces to 127.0.0.1, the local loopback address, you will not be able to connect to Sync Gateway from another host with that config.
To prove that connectivity is working change your binding address to 0.0.0.0, this will allow connections from all hosts.
I did tried with 0.0.0.0 but gives the error below in screenshot.
I have installed Sync_Gateway 1.3.1 Enterprise version. I was just wondering if this is because of any compatibility issue of this version with Windows. Or is it like we need to install first the basic 1.3.0 version and then do upgrade it to 1.3.1.
Sorry Andy. Guess I took the wrong screenshot. I did tried with 4984 port but it gives the starting status but doesnot get connected.
Few points I want to mention:-
My Couchbase server and CB Sync gateway are both installed in same system. Shall it be on different machines?
When I am doing netstat -n, I cant find 4985 and 4984 listed. So does these 2 ports require to be opened separately as, as per site, installation of sync_gateway should by default do that?
3.I have installed Sync_Gateway 1.3.1 Enterprise version. I was just wondering if this is because of any compatibility issue of this version with Windows. Or is it like we need to install first the basic 1.3.0 version and then do upgrade it to 1.3.1.