Replies: 15 comments 4 replies
-
Do limits based on other fields such as user ID work? |
Beta Was this translation helpful? Give feedback.
-
I checked, it doesn't work either. |
Beta Was this translation helpful? Give feedback.
-
Thanks for checking. Can you share your cache settings? You mentioned |
Beta Was this translation helpful? Give feedback.
-
I think I fixed my issue, before I used
Then I found one Stackoverflow question about that multiple gunicorn workers can have their own cache dict and because of it they cannot share the saved values. So, I changed my Memcached config to unix socket with following setting:
Then it worked. Thanks for your attention UPD. Sorry, actually it didn't fix my issue anyway. This is my memcached configuration:
|
Beta Was this translation helpful? Give feedback.
-
Silly question @bzimor : but are you setting I only ask as I found your issue when trying to see why the rate limiter didn't work for me. Not sure why |
Beta Was this translation helpful? Give feedback.
-
Thanks for your advice. Strange, if I use |
Beta Was this translation helpful? Give feedback.
-
Can you show what you’re setting for the view?
…On Sun, 31 Jan 2021 at 13:04, Boburmirzo Hamraqulov < ***@***.***> wrote:
Thanks for your advice. Strange, if I use block=True, it ignores the
limit and it always shows 403 error whenever I access that url.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#222 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIDNATHVRDI4KXDTAYT623S4VIPTANCNFSM4WTAJWMQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Huh wow I’m going to be honest, I haven’t been working in Django lately and the default has been Digging way back into my memory, I believe the intent was twofold
But thinking about it now, with eyes that haven’t seen it in a while, I feel like Obviously this would be a major API change and require a major version bump, but we may need to do v4 anyway to namespace the package. |
Beta Was this translation helpful? Give feedback.
-
@SimonHurst , this is my view:
|
Beta Was this translation helpful? Give feedback.
-
You might want to set a value for m. '200/<n>m' n being the number of
minutes.
…On Sun, 31 Jan 2021 at 16:25, Boburmirzo Hamraqulov < ***@***.***> wrote:
@SimonHurst <https://github.com/SimonHurst> , this is my view:
@ratelimit(key='ip', rate='200/m', block=True)
def test_view(request):
s = request.META.get('HTTP_X_REAL_IP')
return HttpResponse('your ip is ' + s)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIDNAVBZELEH3DI7PCUSQLS4WAAHANCNFSM4WTAJWMQ>
.
|
Beta Was this translation helpful? Give feedback.
-
I logged ratelimit variables on core.py and I got this:
I found that I got blocked because count is |
Beta Was this translation helpful? Give feedback.
-
Sorry deleted that last comment, didn't read it properly. I would still be explicit:
Only because it's a little more obvious if someone else has tor read it later. My next question is what is your caching policy on that view? |
Beta Was this translation helpful? Give feedback.
-
To keep issues cleaner but still help with debugging, I’m going to move this to Discussions (it’ll be the very first one!) |
Beta Was this translation helpful? Give feedback.
-
Can you go into the Django shell and write/read something to/from the cache? It seems like it’s still having issues there. If you’re running memcached with Given that it’s not finding a count at all, it really sounds to me like the cache connection doesn’t work. |
Beta Was this translation helpful? Give feedback.
-
Thank you, I changed python memcached lib , then I checked with django shell and now I can set and get cache by key. Hovewer, I have another problem now. This is from my custom ratelimit log:
You can see the same keys but no count increment. I checked that key, its value was 1. What can be wrong then? I thought this was because of multiple workers of gunicorn, but I am not sure. |
Beta Was this translation helpful? Give feedback.
-
Ratelimit based on user ip doesn't work completely on Django 3 app. Initially, it raised an error due to the absence of
REMOTE_ADDR
and this error was fixed with a new patch on main branch. Although, it can access to the user ip, it doesn't block any over limit on production. However, it works when I run the project usingrunserver 0.0.0.0:8000
.I deployed my django app with the following configurations:
nginx:
gunicorn:
I added this setting:
Also, I checked with
PyMemcacheCache
andLocMemCache
, even I tried with custom middleware to changeREMOTE_ADDR
header, but no luck.Any ideas?
Django version is 3.1.5.
Beta Was this translation helpful? Give feedback.
All reactions