目前我有这个 python 代码来测试 AWS redis 连接,它因连接超时而失败。你能帮我解决一下吗?
import redis, time, datetime, sys
endpoint='myred-0041.dpchko.0001.amazonaws.com'
def prepareConn(endpoint):
r = redis.StrictRedis(host=endpoint, port=6379, db=0, socket_timeout=1)
return r
r = prepareConn(endpoint)
while True:
print(datetime.datetime.now())
try:
print(r.set('foo','bar'))
except:
print "Unexpected error:", sys.exc_info()[0]
time.sleep(1)
最佳答案
我找到了解决方案,AWS 有一些限制使我的本地电脑无法连接到 AWS Redis,然后我在本地安装了 redis https://redis.io/并将端点替换为 endpoint=' http://localhost '
但在生产部署中我使用 AWS redis,它运行良好
关于Python - 连接到 AWS Redis 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49488458/