spring cloud gateway RequestRateLimiter redis, does not detect redis #9866
Unanswered
olivercruz
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am developing a project with Spring Cloud Gateway, where I am adding rate limit with Redis when creating the jar and running it, the rate limit configuration with Redis works correctly and it detects Redis.
org.springframework.boot
spring-boot-starter-data-redis-reactive
routes:
- id: mock
uri: https://jsonplaceholder.typicode.com
predicates:
- Path=/todos/1
filters:
- name: RequestRateLimiter
args:
'[redis-rate-limiter.requestedTokens]': 1
'[redis-rate-limiter.replenishRate]': 1
'[redis-rate-limiter.burstCapacity]': 1
key-resolver: "#{@ipKeyResolver}"
public class IpKeyResolver implements KeyResolver {
}
java -jar target/gateway-0.0.1-SNAPSHOT.jar
I obtain status 429 from Many Request
When I create the native image with graalvm, that's where I have the issue that redis is not recognized.
./mvnw clean -Pnative native:compile -DskipTests
I tried adding reflect-config.json , but the problem still persists
I tried adding redis in code and in the yml file, but without success
@configuration
public class RedisConfig {
@bean
@primary
ReactiveRedisConnectionFactory reactiveRedisConnectionFactory() {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration("127.0.0.1", 6379);
redisStandaloneConfiguration.setPassword("oliver10");
return new LettuceConnectionFactory(redisStandaloneConfiguration);
}
}
pring:
data:
redis:
host: localhost
port: 5672
password: 12345
ssl:
enabled: false
timeout: 5000
lettuce:
pool:
max-idle: 20
min-idle: 10
max-active: 100
max-wait: 1000
I share the example link
https://github.com/olivercruz/gateway_ratelimit_redis
Beta Was this translation helpful? Give feedback.
All reactions