PouchDB复制返回一个静默错误



我真的是沙发/育儿袋的新手,所以我会严格指出这个问题:我有一个沙发服务器,它包含一个_users数据库,我为里面的每个用户建立了一个个人数据库(这很好(。在AngularJS应用程序中,我需要同步(从服务器到客户端的一种方式(pouchDB。这是我的代码:

if($.isEmptyObject(server_params)) {
throw "Server Params not initialized";
}
var remote_connection_string = server_params.protocol + db_name + ":" + passwd + "@" + server_params.domain + "/" + db_name;
var allow_origin_object = {};
if (server_params.origin) {
allow_origin_object = {
fetch: function (url, opts) {
opts.headers.set('Access-Control-Allow-Origin', server_params.origin);
return pouchDB.fetch(url, opts);
}
};
}
var local_db = new pouchDB({
auto_compaction: true,
name: db_name
});
var remote_db = new pouchDB(remote_connection_string, allow_origin_object);
var handler = local_db.replicate.from(remote_db, {});
handler.on('change', function (info) {
console.log(info, arguments);
}).on('paused', function (err) {
console.log(err, arguments);
}).on('active', function () {
console.log("Active!", arguments);
}).on('denided', function (err) {
console.log(err, arguments);
}).on('complete', function (info) {
console.log(info, arguments);
}).on('error', function (err) {
console.log(err, arguments);
}).then(function () {
console.log("then - resolve: ", arguments);
}, function () {
console.log("then - reject: ", arguments);
}).finally(function () {
console.log("finally: ", arguments);
});

在执行时,我在错误部分得到了console.log(从脚本行号看到(,并分别得到了失败的"then",并得到了以下响应:

t {result: {…}}
result:
doc_write_failures: 0
docs_read: 0
docs_written: 0
end_time: "2018-07-16T14:58:15.832Z"
errors: Array(0)
length: 0
__proto__: Array(0)
last_seq: 0
ok: false
start_time: "2018-07-16T14:58:15.828Z"
status: "aborting"
__proto__: Object
__proto__: Error
Arguments [t, callee: ƒ, Symbol(Symbol.iterator): ƒ]
0: t {result: {…}} //same as before
callee: ƒ (err)
length: 1
Symbol(Symbol.iterator): ƒ values()
__proto__: Object
then - reject: Arguments [t, callee: ƒ, Symbol(Symbol.iterator): ƒ]
0: t {result: {…}} //Same as before
callee: ƒ ()
length: 1
Symbol(Symbol.iterator): ƒ values()
__proto__: Object

最后,这是执行时的couchDB服务器日志:

[notice] 2018-07-16T14:58:14.936265Z couchdb@127.0.0.1 <0.27495.232> ace657cb79 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 2
[notice] 2018-07-16T14:58:14.938101Z couchdb@127.0.0.1 <0.27714.232> 0f8058a082 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 1
[notice] 2018-07-16T14:58:15.643560Z couchdb@127.0.0.1 <0.27421.232> 7109b0fe1c 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 1
[notice] 2018-07-16T14:58:15.644622Z couchdb@127.0.0.1 <0.29430.232> 62ae5b985c 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 0
[notice] 2018-07-16T14:58:15.676596Z couchdb@127.0.0.1 <0.27058.232> 525bfaef78 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 1
[notice] 2018-07-16T14:58:15.677802Z couchdb@127.0.0.1 <0.27216.232> a5bfb296e2 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 1
[notice] 2018-07-16T14:58:15.729505Z couchdb@127.0.0.1 <0.27325.232> 3a7ef79eee 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 5
[notice] 2018-07-16T14:58:15.730669Z couchdb@127.0.0.1 <0.27271.232> 859e6a7a77 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 1
[notice] 2018-07-16T14:58:15.899331Z couchdb@127.0.0.1 <0.29372.232> bab85b4599 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 2
[notice] 2018-07-16T14:58:15.900569Z couchdb@127.0.0.1 <0.29451.232> a7814fa0d6 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 1
[notice] 2018-07-16T14:58:16.194140Z couchdb@127.0.0.1 <0.27487.232> a33e1cf89a 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 2
[notice] 2018-07-16T14:58:16.195184Z couchdb@127.0.0.1 <0.27437.232> d83fa88258 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 1
[notice] 2018-07-16T14:58:16.374816Z couchdb@127.0.0.1 <0.27374.232> 7e3181a5fe 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 2
[notice] 2018-07-16T14:58:16.375180Z couchdb@127.0.0.1 <0.26122.232> 63dd14607c 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 2
[notice] 2018-07-16T14:58:16.376273Z couchdb@127.0.0.1 <0.26973.232> dbe6cbfbfe 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 0
[notice] 2018-07-16T14:58:16.377752Z couchdb@127.0.0.1 <0.26655.232> 1dc92196a6 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 0
[notice] 2018-07-16T14:58:16.380779Z couchdb@127.0.0.1 <0.26974.232> 6f551e8c54 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 4
[notice] 2018-07-16T14:58:16.381229Z couchdb@127.0.0.1 <0.21323.232> ff863db7bb 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 4
[notice] 2018-07-16T14:58:16.382777Z couchdb@127.0.0.1 <0.26610.232> 05aed374e1 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 1
[notice] 2018-07-16T14:58:16.382818Z couchdb@127.0.0.1 <0.23204.232> 0177b5a85c 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 1
[notice] 2018-07-16T14:58:16.383940Z couchdb@127.0.0.1 <0.26937.232> a62c233ddc 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-a713a2af2eb25c57ba17548 409 ok 5
[notice] 2018-07-16T14:58:16.384476Z couchdb@127.0.0.1 <0.27032.232> e7938336f1 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-dbba7695d17cdec2cc6dc94 409 ok 1
[notice] 2018-07-16T14:58:16.384887Z couchdb@127.0.0.1 <0.26874.232> 3bc9bbc043 127.0.0.1:5984 127.0.0.1 client GET /user-a713a2af2eb25c57ba17548/_security 200 ok 1
[notice] 2018-07-16T14:58:16.385498Z couchdb@127.0.0.1 <0.26751.232> b1644014a0 127.0.0.1:5984 127.0.0.1 client GET /user-dbba7695d17cdec2cc6dc94/_security 200 ok 1
[notice] 2018-07-16T14:58:16.387350Z couchdb@127.0.0.1 <0.27782.232> 9dd4b8a07e 127.0.0.1:5984 127.0.0.1 undefined PUT /_users/org.couchdb.user%3Auser-5cd8241f12f4f91ba20feb3 409 ok 1
[notice] 2018-07-16T14:58:16.388264Z couchdb@127.0.0.1 <0.26625.232> eec2e12357 127.0.0.1:5984 127.0.0.1 client GET /user-5cd8241f12f4f91ba20feb3/_security 200 ok 0

当然同步失败了。有什么帮助吗?非常感谢

您确定remote_connection_string的格式正确吗?如果你的远程数据库有用户名和密码,它应该看起来像:

https://username:password@hostname/databasename

但在你的代码中,它看起来像你有:

https://databasename:password@hostname

因此,我认为值得检查的是,在解决可能的复制问题之前,您是否可以返回基本的数据库信息。

最新更新