问题
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:
I printed c (Couchbase connection object) out
The object was created so it connected to Couchbase server successfully?
- I tried to telnet remote-server.com at port 8091, it connected successfully, too.
- 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