How to hit the sync url included with the AMI for Amazon

I recently downloaded and ran the pre-built couch base server + sync gateway on ec2.
I have the server running and I can hit it at port 8091. I see in the home directory a sync_gateway.zip. I unzipped it and ran ./sync_gateway ~/config.json. The ports are set for the default gateway ports, but I cannot access them. Do I need to open up ports on the ec2 instance? I thought being prebuilt everything including the sync gateway would be set up. I'm new to couch base and still coming up to speed.

Thank you

Hmm. Thanks for reporting, we're checking this out. Any other information you can give? The default ports are 4984 for the Sync Gateway's sync REST API and 4985 for the admin interface. What kind of error are you seeing when you try to access Sync Gateway?

1 Answer

« Back to question.

Ok, I got it up and running. I think perhaps I didn't have the sync_gateway running when I thought I did. I checked and saw port 4984 available but found nothing was listening on it. I restarted the sync_gateway. I was able to use the url in a browser to hit the gateway. I was prompted for a usename and password and so I used the Admin interface to create a user using persona login.

curl -X PUT http://localhost:4985/sync_gateway/_user/myUser -d '{"email":"myUser@myEmail.com", "password":"password"}'

I modified the config.json to use the new user:

{
    "interface": ":4984",
    "adminInterface": ":4985",
    "log": ["REST"],
    "persona": {"origin": "http://localhost:4984/", "register": true},
    "databases": {
        "sync_gateway": {
            "server": "http://localhost:8091",
            "bucket": "sync_gateway",
            "users": {
               "GUEST": {"disabled": true}
            },
            "sync": `function(doc) {channel(doc.channels);}`
        }
}

then I could access the gateway in the browser and get some information on it.

I was building a client using the couchbase mobile Titanium module example. The example uses a sync_gateway URL but I'm not sure where I would supply the authentication credentials?

Thanks

Persona will present a UI and then give you an "assertion" which you can register with Couchbase Lite. The next time you sync Couchbase Lite will handshake with the server and use the assertion to ask the server to set an HTTP cookie. This HTTP cookie is what authenticates subsequent sync requests.

There's a complex state machine there. I used this code to deal with it on iOS. It shouldn't be hard to build something similar on Titanium.