Error with sessions on redis

73 views
Skip to first unread message

Áureo Dias Neto

unread,
Nov 5, 2019, 7:28:53 AM11/5/19
to web2py-users
Part of db.py file for connection with redis:

from gluon.contrib.redis_utils import RConn
rconn = RConn('localhost:6379')
from gluon.contrib.redis_session import RedisSession
sessiondb = RedisSession(redis_conn=rconn, with_lock=True, session_expiry=3600)
session.connect(request, response, db = sessiondb)


Error when try to run the app:


Traceback (most recent call last):
File "/gestaopatio/web2py/gluon/main.py", line 460, in wsgibase
session._try_store_in_db(request, response)
File "/gestaopatio/web2py/gluon/globals.py", line 1238, in _try_store_in_db
record_id = table.insert(**dd)
File "/gestaopatio/web2py/gluon/contrib/redis_session.py", line 146, in insert
pipe.execute()
File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 3691, in execute
return execute(conn, stack, raise_on_error)
File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 3557, in _execute_transaction
if EMPTY_RESPONSE not in options])
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 761, in pack_commands
for chunk in self.pack_command(*cmd):
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 737, in pack_command
for arg in imap(self.encoder.encode, args):
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 107, in encode
raise DataError("Invalid input of type: 'bool'. Convert to a "
DataError: Invalid input of type: 'bool'. Convert to a byte, string or number first.

I think the problem is the last line, but not added any custom field do session table

Jose C

unread,
Nov 8, 2019, 3:09:32 AM11/8/19
to web2py-users
I can't reproduce this error with my particular setup.  Can you post details about which versions of software you're running?  Specifically web2py, python, py-redis module, redis itself and which os?




Áureo Dias Neto

unread,
Nov 8, 2019, 6:30:58 AM11/8/19
to web...@googlegroups.com
Hello, yes:

Web2py: 2.18.5-stable+timestamp.2019.04.08.04.22.03 (running on
gunicorn/19.9.0, Python 2.7.15+)
py-redis: 4.0.9
Redis server v=4.0.9 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64
build=9435c3c2879311f3
redis-cli 4.0.9
OS: Ubuntu 18.04.1 LTS

Em sex., 8 de nov. de 2019 às 05:09, Jose C <houdini...@gmail.com> escreveu:
>
> I can't reproduce this error with my particular setup. Can you post details about which versions of software you're running? Specifically web2py, python, py-redis module, redis itself and which os?
>
>
>
>
> --
> 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 a topic in the Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/F7_iN3p0nEc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/2b63e25a-c1df-4b0d-9a85-6805f5f29fae%40googlegroups.com.

Jose C

unread,
Nov 8, 2019, 7:14:08 AM11/8/19
to web2py-users

Web2py: 2.18.5-stable+timestamp.2019.04.08.04.22.03 (running on
gunicorn/19.9.0, Python 2.7.15+)
py-redis: 4.0.9
Redis server v=4.0.9 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64
build=9435c3c2879311f3
redis-cli 4.0.9
OS:  Ubuntu 18.04.1 LTS

 
HI Aureo,
Which version of the python redis library is being used? You can get it by running:
>>> import redis
>>> redis.__version__

 

Áureo Dias Neto

unread,
Nov 8, 2019, 7:23:27 AM11/8/19
to web...@googlegroups.com
3.3.11
> --
> 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 a topic in the Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/F7_iN3p0nEc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/b02e4a12-cd5e-4a2a-9a3c-c05300fa29a4%40googlegroups.com.

Jose C

unread,
Nov 8, 2019, 7:41:13 AM11/8/19
to web2py-users
Hi Aureo,

You're hitting a bug in web2py's redis session implementation that does not yet have a fix.  Basically redis cannot be used for sessions at this stage with web2py 2.18.5 and either versions 2 or 3 of the redis python library.


Hopefully someone with more in-depth knowledge of web2py's workings will attack this bug soon.


Áureo Dias Neto

unread,
Nov 8, 2019, 7:53:58 AM11/8/19
to web...@googlegroups.com
What do you think about Joe Barnhart's solution?
My point with redis is that I am using database sessions, finally my
goal is to unburden it since I have plenty of RAM on the application
server ...
> --
> 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 a topic in the Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/F7_iN3p0nEc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/f2570fdd-028d-48b5-8fab-d3707afa85c9%40googlegroups.com.

Jose C

unread,
Nov 8, 2019, 8:14:06 AM11/8/19
to web2py-users

What do you think about Joe Barnhart's solution?
My point with redis is that I am using database sessions, finally my
goal is to unburden it since I have plenty of RAM on the application
server ...

I haven't tried it but as Joe says his patch was rejected but I'm not sure why.  Could be it causes some other problems.

Áureo Dias Neto

unread,
Nov 8, 2019, 8:19:29 AM11/8/19
to web...@googlegroups.com
Okay, thanks for the attention on the answers, hug!
> --
> 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 a topic in the Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/F7_iN3p0nEc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/bedc7b4f-03ca-4a02-905c-2bec885b004e%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages