NSLog in CBLite.m reports Couchbase Lite url = http://lite.couchbase?

var db = cblite.database(user.database);
            // success
            function(data) {
                console.log("cblite success", data);
                prepared = true;
                checkDesignDocs(db, user);
            // failure
            function(err) {
                console.log("cblite failure", err);

We’re using angular-couchbase with the couchbase lite plugin on iOS (this is a cordova app). The call above to create the database fails with the error:

Unable to create database: ""

(The value in quotes is supposed to be an error message but its empty so not very informative :smile: I’m wondering if there’s anything I missed (permissions?) or some hints on how to troubleshoot this?


Seems to me deviceReady() never gets called in angular-couchbase-lite.js on iOS but the same codebase works fine on Android.


We think the error is at a lower level and so the higher layers in JS fail. Specifically, in CBLite.m we see this logging code:

NSLog(@"Couchbase Lite url = %@", self.liteURL);

The actual console log message when running on a device shows:

Couchbase Lite url = http://lite.couchbase./

Shouldn’t that be http://localhost:5984/ ?


No, that’s the correct value. Couchbase Lite does not open a real TCP port (that would be a security hole and is also more expensive); instead it installs a handler that recognizes HTTP requests for URLs with hostnames matching “lite.couchbase.”


OK, this is different than the Android side where we simply talk REST to localhost (which also explains why we get a hostname lookup failure for lite.couchbase). We’re using the PhoneGap plugin from JS code, so how does that work on the iOS side?


So this appears to work:

    success(function(data, status, headers, config) {
        console.log('GET lite.couchbase SUCCESS: ', data);
        window.cblite.getURL(function(err, url) {
            console.log('ERR: ', err, 'URL: ', url);
    error(function(data, status, headers, config) {
        console.log('GET lite.couchbase FAILED: ', data);

so the problem is at a higher level in our stack, probably assumptions made in angular-couchbase.


It works exactly the same way on both platforms; just use the URL you’re given and don’t make assumptions about what it looks like :smile:


FYI, turns out angular-couchbase was parsing and reconstructing this URL in a way that causes the failure on iOS but not on Android.


What exactly did it do? We should try to find a way around this, in case others run into the problem. (Actually please file this as an issue on Github. Thanks!)


I think we’re gonna be submitting PRs to the angular-couchbase folks.