Remote db access fails with error.name = "unknown"

275 views
Skip to first unread message

Charles Palmer

unread,
Mar 16, 2017, 8:31:50 PM3/16/17
to PouchDB
I am trying PouchDB with Cordova on an Android phone. Local databases work but attempts to communicate with my remote database at cloudant.com fail with an error message I can't interpret, including error.name = "unknown". Where can I find a fully-worked example that works with cloudant.com databases, including aspects such as authorisation and CORS? Online examples skip this.

Here's the code that fails:

    remoteDb = new PouchDB("https://myaccount.cloudant.com/mmm_test_1/",
        {auth: {username: "myusername",
        password: "mypassword"}});

    var rep = PouchDB.replicate(localDb, remoteDb, {
        live: false,   
        retry: false
    }).on('change', function (info) {
          console.log('Changed' + info);
    /* snip - other events handled here */          
    }).on('error', function (err) {
          console.log('On error: ' + JSON.stringify(err));
    });

and the console output is:
On error: {"status":0,"name":"unknown","message":"getCheckpoint rejected with ","result":{"ok":false,"start_time":"2017-03-15T09:52:16.884Z","docs_read":0,"docs_written":0,"doc_write_failures":0,"errors":[],"status":"aborting","end_time":"2017-03-15T09:52:17.160Z","last_seq":0}}

BTW - JSON.stringify(remoteDb) works before the replicate() call but fails afterwards, with "Uncaught TypeError: Converting circular structure to JSON" - i have traced this to remoteDb.taskqueue

I am using pouchdb-6.1.2.js. If I use pouchdb-3.3.0.min.js it also fails but the errors are different:
On error: {"status":500,"name":"unknown_error","message":"Database encountered an unknown error","error":true}
JSON.stringify(remoteDb) works, but remoteDb.name becomes "undefined".

I am able to access my cloudant.com database with the same username and password - this Node-RED example shows how: http://flows.nodered.org/flow/411bab7d9872bac32ad1ebba06c14a37

Charles Palmer

unread,
Mar 22, 2017, 12:12:50 PM3/22/17
to PouchDB
Just a note to report that I resolved this problem. It was a newbie problem related to missing or mis-configured cordova-plugin-whitelist. (though it would have been faster to catch with a relevant error message).

I have been playing and find this is a very impressive package. Thanks!
Reply all
Reply to author
Forward
0 new messages