2
Spring Cloud Gateway global filter throwing **Only one connection receive subscriber allowed.** when logging response from getting exchange.

Getting response from ServerWebExchange

Connection connection = exchange.getAttribute(CLIENT_RESPONSE_CONN_ATTR); 

After getting connection object to get NettyDataBuffer

    Flux<NettyDataBuffer> bodyNettyDataBuffer = connection.inbound().receive().retain().map(factory::wrap);

Then Subscriber to log request and it is failing here

bodyNettyDataBuffer.subscribe(buffer -> {

Initializing byte array

                byte[] dst = new byte[buffer.capacity()];

slice to buffer to get byter array value

                buffer.getNativeBuffer().slice().getBytes(0, dst);

converting into string and logging

                LOGGER.info("Response Body:{}", new String(dst));
            });
  • 1
    This is already answered https://stackoverflow.com/questions/54117061/springcloudgateway-log-incoming-request-url-and-corresponding-route-uri – Patrick Magee May 18 '20 at 00:58
  • 1
    Does this answer your question? [SpringCloudGateway - Log incoming request url and corresponding route URI](https://stackoverflow.com/questions/54117061/springcloudgateway-log-incoming-request-url-and-corresponding-route-uri) – Narvalex May 18 '20 at 04:48
  • Using spring cloud gateway 2.1.2 and using custom logging instead of spring boot logging. But not working for me. – Sarma Vemparala May 18 '20 at 13:37

0 Answers0