spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

Spring Cloud Gateway Exceeded limit on max bytes to buffer : 262144 Error

Open liuxiaobo129 opened this issue 5 months ago • 1 comments

I uploaded a large JSON structure (a menu tree) from the frontend. When it reaches the gateway, it throws the following error:

DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144

I’m using Spring 6 and Spring Cloud Gateway 4.

The first approach doesn’t work spring: codec: max-in-memory-size: 10MB cloud: gateway: httpclient: response-timeout: 30s connect-timeout: 10000

The second approach doesn’t work @Bean public WebFluxConfigurer webFluxConfigurer() { return new WebFluxConfigurer() { @Override public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) { configurer.defaultCodecs().maxInMemorySize(10 * 1024 * 1024); } }; }

liuxiaobo129 avatar Jul 26 '25 02:07 liuxiaobo129

@liuxiaobo129 : Honestly, I don't know the root cause of your problem, but just by looking your configuration I believe you are trying to use deprecated configuration:

spring.codec.max-in-memory-size is replaced by spring.http.codecs.max-in-memory-size

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.5.0-RC1-Release-Notes#deprecations-in-spring-boot-350-rc1

janossch avatar Aug 15 '25 07:08 janossch