redis in 2.16.1

86 views
Skip to first unread message

黄祥

unread,
Jun 19, 2018, 9:17:35 PM6/19/18
to web2py-users
it seems session with redis not work in 2.16.1
e.g. create web2py from scratch name redis
models/db.py
from gluon.contrib.redis_utils import RConn
from gluon.contrib.redis_cache import RedisCache
from gluon.contrib.redis_session import RedisSession
rconn
= RConn('localhost', 6379)
cache
.redis = RedisCache(redis_conn = rconn, debug = True)
sessiondb
= RedisSession(redis_conn = rconn, session_expiry = False)
session
.connect(request, response, db = sessiondb)

Traceback (most recent call last):
 
File "/Users/sugizo/web2py/gluon/main.py", line 461, in wsgibase
    session
._try_store_in_db(request, response)
 
File "/Users/sugizo/web2py/gluon/globals.py", line 1224, in _try_store_in_db
    record_id
= table.insert(**dd)
 
File "/Users/sugizo/web2py/gluon/contrib/redis_session.py", line 137, in insert
    newid
= str(self.db.r_server.incr(self.serial))
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/client.py", line 1011, in incr
   
return self.execute_command('INCRBY', name, amount)
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/client.py", line 667, in execute_command
    connection
.send_command(*args)
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 610, in send_command
   
self.send_packed_command(self.pack_command(*args))
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 585, in send_packed_command
   
self.connect()
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 493, in connect
   
self.on_connect()
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 567, in on_connect
   
if nativestr(self.read_response()) != 'OK':
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 629, in read_response
   
raise response
ResponseError: invalid DB index

also, is it possible to use redis secured with password in web2py?
e.g.
redis.conf
requirepass password

models/db.py
rconn = RConn('localhost', 6379, 'password')
#sessiondb = RedisSession(redis_conn = rconn, session_expiry = False)
#session.connect(request, response, db = sessiondb)

Traceback (most recent call last):
 
File "/Users/sugizo/web2py/gluon/main.py", line 461, in wsgibase
    session
._try_store_in_db(request, response)
 
File "/Users/sugizo/web2py/gluon/globals.py", line 1224, in _try_store_in_db
    record_id
= table.insert(**dd)
 
File "/Users/sugizo/web2py/gluon/contrib/redis_session.py", line 137, in insert
    newid
= str(self.db.r_server.incr(self.serial))
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/client.py", line 1011, in incr
   
return self.execute_command('INCRBY', name, amount)
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/client.py", line 667, in execute_command
    connection
.send_command(*args)
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 610, in send_command
   
self.send_packed_command(self.pack_command(*args))
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 585, in send_packed_command
   
self.connect()
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 493, in connect
   
self.on_connect()
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 567, in on_connect
   
if nativestr(self.read_response()) != 'OK':
 
File "/Users/MacBookPro/miniconda3/envs/python2_prod/lib/python2.7/site-packages/redis/connection.py", line 629, in read_response
   
raise response
ResponseError: NOAUTH Authentication required.

any hints?

thx and best regards,
stifan

Richard Vézina

unread,
Jun 29, 2018, 4:07:44 PM6/29/18
to web2py-users
Is in your issue web2py the only moving part?? Nothing change on OS and Redis side??

As it mention in the final trace back above there seems to need a password to be setup in your redis connection string... Perhap you forgot that you set one or there is a default one defined in you Linux box or in the new version of Redis????

Richard

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

黄祥

unread,
Jun 29, 2018, 6:12:37 PM6/29/18
to web2py-users
Is in your issue web2py the only moving part?? Nothing change on OS and Redis side??
 
for existing app it works (same web2py version, same os and same redis server), but when start new web2py app it return an error. 
ResponseError: invalid DB index


As it mention in the final trace back above there seems to need a password to be setup in your redis connection string... Perhap you forgot that you set one or there is a default one defined in you Linux box or in the new version of Redis????
 
for password it's still not work even in existing app, i suspect is wrong with my configuration, not sure
redis.conf
requirepass password

models/db.py
rconn = RConn('localhost', 6379, 'password')

result
ResponseError: NOAUTH Authentication required.

any hints for password error? how to setup a password in redis connection string?

thx n best regards,
stifan

Leonel Câmara

unread,
Jun 29, 2018, 8:43:55 PM6/29/18
to web2py-users
Have you set password "password" for localhost using redis-cli?

redis-cli -h localhost -p 6379 -a password

黄祥

unread,
Jun 30, 2018, 12:22:32 AM6/30/18
to web2py-users
yes, can do, no problem on redis part
$ ./src/redis-cli -h localhost -p 6379 -a password
Warning: Using a password with '-a' option on the command line interface may not be safe.
localhost
:6379> ping
PONG
localhost
:6379>

$ ./src/redis-cli -a password monitor
Warning: Using a password with '-a' option on the command line interface may not be safe.
OK
1530331699.614717 [0 127.0.0.1:53577] "AUTH" "password"
1530331699.615113 [0 127.0.0.1:53577] "COMMAND"
1530331707.001400 [0 127.0.0.1:53577] "ping"

step i took on redis (dev env)
curl -L -O -C - http://download.redis.io/redis-stable.tar.gz
tar xvzf redis
-stable.tar.gz
sed
-i '' 's/# requirepass foobared/requirepass password/g' redis-stable/redis.conf
mv redis
-stable/ redis
cd redis
make
./src/redis-server ./redis.conf

note:
- ResponseError: invalid DB index problem occured when using session for new web2py app. no error occured when using redis session and redis cache on existing web2py app.
- ResponseError: NOAUTH Authentication required. problem occured when activate password on redis server (requirepass), when comment requirepass on redis.conf, no error occured

any clue?
Reply all
Reply to author
Forward
0 new messages