Couple of points: > I have figured out a way to add interceptor in server builder to add compression with type gzip
You don't need an interceptor to add custom codec compression on the server side. Just use ServerBuilder.compressorRegistry(CompressorRegistry) <https://github.com/grpc/grpc-java/blob/master/api/src/main/java/io/grpc/ServerBuilder.java#L233> to use your own compressor registry with custom codecs (snappy and gzip) added. > But in such cases I would want server to do gzip compression rather than identity. Is this possible ? Unfortunately not because of this code <https://github.com/grpc/grpc-java/blob/master/core/src/main/java/io/grpc/internal/ServerCallImpl.java#L118>. In that case you can use an interceptor to check the accept-encoding header from the client and based on that set the snappy compression on the call only if client accepts it. On Thursday, July 1, 2021 at 12:19:35 PM UTC-7 gokul.ml...@gmail.com wrote: > Hi team, > > I have been trying to understand the grpc java compression decompression > logic, but am having hard time on how to have server to compress response > messages based on what client accepts. Here is my understanding so far - > > > 1. On the client side - using the following link I am setting the > compression type to gzip. This is compressing all messages sent from client > to server > > https://grpc.github.io/grpc-java/javadoc/io/grpc/stub/AbstractStub.html#withCompression-java.lang.String- > 2. For messages back from server - I have figured out a way to add > interceptor in server builder to add compression with type gzip. This does > perform compressing, but this is introducing a constraint on server. If for > example I specify 'snappy' (custom codec) here in place of gzip in server > builder, (client has default compressor registry, so supports identity and > gzip only) my understanding is negotiation fails as 'snappy' is not > supported by client and falls back to identity. But in such cases I would > want server to do gzip compression rather than identity. Is this possible ? > By this server compresses messages based on what client accepts > > > Thanks in advance! > > > Thanks and regards, > Gokul > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/4a695696-5e1b-4952-bec9-f23cf4f98618n%40googlegroups.com.