Insert into remote Couchbase server by Python

久未见 提交于 2019-12-10 17:17:00

问题


I use this code to insert data into Couchbase

from couchbase import Couchbase

c = Couchbase.connect(host="remote-server.com", bucket="default")
c.set('first_key', 'first-_value')

But I got this error:

couchbase.exceptions.TimeoutError: <Key=u'first_key', RC=0x17[Operation timed out], Operational Error, Results=1, C Source=(src/multiresult.c,148)>

And, I tried these steps:

  1. I printed c (Couchbase connection object) out

    The object was created so it connected to Couchbase server successfully?

  2. I tried to telnet remote-server.com at port 8091, it connected successfully, too.
  3. Increase timeout connection to 30 seconds.

But, the problem has not been solved.


回答1:


To connect to couchbase you should ensure that your server is configured with dns name remote-server.com, not IP, not localhost. And couchbase server also should be able to get ip via this dns name.

I.e. if you host your server in AWS EC2, couchbase usally get internal IP address like 10.X.X.X and even if you try to access it from internet via public ip with clien library, your request will be timed out. But you will be able to access REST API, and admin console via public dns.

Also you should check all ports (not only 8091) needed by couchbase. See this doc for all ports needed to be opened.



来源:https://stackoverflow.com/questions/19682658/insert-into-remote-couchbase-server-by-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!