gpt4 book ai didi

ubuntu - PouchDB - 尝试连接到 CouchDB 时为 "Database encountered an unknown error"

转载 作者:太空宇宙 更新时间:2023-11-03 16:56:04 25 4
gpt4 key购买 nike

我正在尝试设置 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-couchdbadd-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 吗?

如有任何帮助,我们将不胜感激!

谢谢,戴夫

最佳答案

听起来您需要为您的 CouchDB 修改 local.ini 文件,以允许从更多 IP 进行访问,而不仅仅是本地主机。

检查此部分的 local.ini:

[httpd]
;port = 5984
;bind_address = 127.0.0.1

将此更改为:

[httpd]
;port = 5984
bind_address = 0.0.0.0

编辑:一个更简单的解决方案是将您的 Nginx/Apache 代理设置为路由 http://example.com/couchdb本地主机:5984。这是我使用的 Nginx 配置:

location /couchdb {
rewrite /couchdb(.*) $1 break;
proxy_pass http://127.0.0.1:5984;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

关于ubuntu - PouchDB - 尝试连接到 CouchDB 时为 "Database encountered an unknown error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28609066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com