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


#1
var db = cblite.database(user.database);
db.createIfMissing().then(
            // 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?


#2

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


#3

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/ ?


#4

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.”


#5

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?


#6

So this appears to work:

$http.get('http://lite.couchbase.').
    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.


#7

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:


#8

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


#9

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!)


#10

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