Thank you Niphlod, as always :)
I've seen your answer in the other post. Sorry for my lack of knowledge :P
Now I understand better.
I was dealing today with a strange error: the same code worked ok when I
run the app with web2py's embedded server, but the app couldnt connect to
redis when I used nginx (the logs showed that there was no redis instance
available, same message every two seconds, until it gave up). *But it was
fixed after restarting the OS*. Sorry, I've should tried that.
Anyway, this code is working ok:
from gluon.contrib.redis_cache import RedisCache
from gluon.contrib.redis_utils import RConn
rconn = RConn('localhost', 6379)
cache.redis = RedisCache(redis_conn=rconn, with_lock=True)
Thanks for your time, sorry for the bother!
Regards,
Lisandro.
El miércoles, 28 de septiembre de 2016, 18:39:25 (UTC-3), Niphlod escribió:
>
> see the other thread. accessing redis through an ssl channel just encrypts
> the traffic from your frontend to the redis instance: it has nothing to do
> with how a user accesses your app (i.e. https or http).
>
> On Wednesday, September 28, 2016 at 9:42:28 PM UTC+2, Lisandro wrote:
>>
>> I think I know what's going on.
>> I've found this post from Niphlod regarding new redis cache:
>>
>> https://groups.google.com/forum/#!searchin/web2py/redis$20unavailable$20instance%7Csort:relevance/web2py/x1CCFWflmV8/POdMQmcYEgAJ
>>
>> There he says: "...want to connect to redis through ssl (previously
>> unavailable)? pass the relevant ssl, ssl_keyfile, etc etc etc to RConn"
>>
>> My app is served with nginx through HTTPS, so I think I would have to
>> pass those parameters to RConn.
>> Does anyone have a working example about that?
>>
>>
>>
>> El miércoles, 28 de septiembre de 2016, 12:54:13 (UTC-3), Lisandro
>> escribió:
>>>
>>> I was using an old web2py version
>>> (2.10.3-stable+timestamp.2015.04.02.21.42.07), but today I've updated to
>>> the last stable (2.14.6-stable+timestamp.2016.05.10.00.21.47).
>>>
>>> I've seen that in the new version of redis_cache the usage has changed.
>>> Before it was like this:
>>>
>>> from gluon.contrib.redis_cache import RedisCache
>>> cache.redis = RedisCache('localhost:6379', with_lock=True)
>>>
>>>
>>> But now, accordingly to the module documentation, it should be like this:
>>>
>>> from gluon.contrib.redis_cache import RedisCache
>>> from gluon.contrib.redis_utils import RConn
>>> rconn = RConn('localhost', 6379)
>>> cache.redis = RedisCache(redis_conn=rconn, with_lock=True)
>>>
>>>
>>> I've made that changes, and *it does work ok when I use web2py embedded
>>> webserver, but when I stop web2py's server and try to access the app
>>> (served through nginx), it can't connect to redis*.
>>> I'm lost there :/
>>>
>>>
>>>
>>>
>>> El miércoles, 28 de septiembre de 2016, 11:52:22 (UTC-3), Marlysson
>>> Silva escribió:
>>>>
>>>> Try look whether a instance of Redis return a type of redis , it is
>>>> like that redis connection are failing and returning a string intead redis
>>>> object. I Think.
>>>>
>>>> Em quarta-feira, 28 de setembro de 2016 11:24:10 UTC-3, Lisandro
>>>> escreveu:
>>>>>
>>>>> Hi there!
>>>>> Recently I've updated web2py to the last stable
>>>>> version 2.14.6-stable+timestamp.2016.05.10.00.21.47
>>>>>
>>>>>
>>>>> ERROR:web2py:Traceback (most recent call last):
>>>>> File "/home/gonguinguen/medios/gluon/restricted.py", line 227, in
>>>>> restricted
>>>>> exec ccode in environment
>>>>> File "/home/gonguinguen/medios/applications/webmedios/models/0.py",
>>>>> line 19, in <module>
>>>>> cache.redis = RedisCache('localhost:6379', with_lock=True)
>>>>> File "/home/gonguinguen/medios/gluon/contrib/redis_cache.py", line
>>>>> 90, in RedisCache
>>>>> with_lock=with_lock, fail_gracefully=fail_gracefully))
>>>>> File "/home/gonguinguen/medios/gluon/contrib/redis_cache.py", line
>>>>> 126, in __init__
>>>>> self._release_script = register_release_lock(self.r_server)
>>>>> File "/home/gonguinguen/medios/gluon/contrib/redis_utils.py", line
>>>>> 69, in register_release_lock
>>>>> rtn = conn.register_script(_LUA_RELEASE_LOCK)
>>>>> AttributeError: 'str' object has no attribute 'register_script'
>>>>>
>>>>>
>>>>> Any ideas on how to solve it?
>>>>> I'm a bit lost. I've tried instantiating RedisCache with_lock=False
>>>>> but the error is the same.
>>>>>
>>>>> Thanks in advance!
>>>>> Regards,
>>>>> Lisandro.
>>>>>
>>>>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.