spring cloud gateway RequestRateLimiter redis, does not detect redis #9866
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
-
close |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
close |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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