【发布时间】:2015-02-20 05:56:58
【问题描述】:
我正在尝试设置 pouchDB 同步,但远程连接到 couchDB 时遇到问题...我已按照 these instructions from couchDB 安装在我的 ubunto 服务器上 - 由 laravel forge 管理...虽然这个项目本身没有使用 laravel(只是一个普通的 html 文件)
一切都已正确安装,所有预期响应
如果我跑:curl localhost:5984
我得到:{"couchdb":"Welcome","uuid":"*******************","version":"1.6.1","vendor":{"version":"14.04","name":"Ubuntu"}}
我跑了:npm install -g add-cors-to-couchdb 和 add-cors-to-couchdb
而且我没有收到任何跨域错误
但是,如果我尝试转到 http://178.xx.xxx.xxx:5984/_utils,它就会挂起?
使用以下代码时:
var localdb = new PouchDB('messages');
var remotedb = new PouchDB('http://178.xx.xx.xx:5984/messages');
localdb.sync(remotedb, {live: true});
我明白了:
Unhandled promise rejection
Promise
{
[[PromiseStatus]]: "rejected",
[[PromiseValue]]: o
}
__proto__: Promise
[[PromiseStatus]]: "rejected"
[[PromiseValue]]: o
error: true
message: "Database encountered an unknown error"
name: "unknown_error"
status: 500
(取自 chrome)
知道为什么我会收到此错误吗?它似乎正在超时......任何想法为什么会这样做?
如果我使用:ssh -L5984:127.0.0.1:5984 forge@178.xx.xx.xx
然后转到http://localhost:5984/_utils/ 它工作正常
将远程地址替换为http://localhost:5984/messages 也会使同步工作
在使用它的同时,我还使用“验证安装”检查了所有内容是否已正确安装,并返回“您的安装看起来不错。是时候放松一下了。”
奇怪!
那么有人知道为什么我不能远程连接到 couchDB 吗?
任何帮助将不胜感激!
谢谢, 戴夫
【问题讨论】: