4

I installed nutcracker 0.4.0 and have this in the config:

redis:
    listen: 127.0.0.1:22121
    hash: fnv1a_64
    distribution: ketama
    auto_eject_hosts: true
    redis: true
    server_retry_timeout: 2000
    server_failure_limit: 10
    servers:
    - 127.0.0.1:6379:1

Code:

 >>> client = redis.StrictRedis(host='127.0.0.1', port=22121, db=1)
 >>> client.set('a', 'b')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sudheer/workspace/pvenvs/p2s/lib/python2.7/site-packages/redis/connection.py", line 137, in _read_from_socket
    (e.args,))
redis.exceptions.ConnectionError: Error while reading from socket: ('Connection closed by server.',)

How can I get Twemproxy to work with redis-py?

Sudheer
  • 710
  • 6
  • 25
  • Is it not possible for you to switch to redis 3.0 which has stable support for clustering ? – DhruvPathak Apr 17 '15 at 09:05
  • "Redis Cluster is the preferred way to get automatic sharding and high availability. It is currently not production ready, but finally entered beta stage, so we recommend you to start experimenting with it. You can get more information about Redis Cluster in the Cluster tutorial. Once Redis Cluster will be available, and if a Redis Cluster compliant client is available for your language, Redis Cluster will be the de facto standard for Redis partitioning." – Sudheer Apr 17 '15 at 10:06
  • That is an outdated document on Redis website. See : http://stackoverflow.com/questions/14941897/redis-cluster-production-ready – DhruvPathak Apr 17 '15 at 10:21
  • Upvoted coz I have Redis 3.2.8 and still hit the same issue as Sudheer, and solved it following his answer as well. I am wondering if there is any way other than being restricted to DB 0. – A. B Sep 06 '17 at 17:58

1 Answers1

3

I figured out the solution to my problem. Python redis client was sending SELECT command when the configuration had URL like: 127.0.0.1:6379?db=1. The db=1 triggers the SELECT command which is not supported by nutcracker. I changed it to db=0 and things work well now.

Sudheer
  • 710
  • 6
  • 25