Skip to content

Firebase calls all fail with java.util.zip.ZipException: Not in GZIP format with apache httpclient 5.6 #1173

Closed

Description

@papegaaij
  • Operating System version: Kubuntu 25.10
  • Firebase SDK version: 9.7.0
  • Library version: _____
  • Firebase Product: messaging

When sending a message with Firebase using Apache Httpclient 5.6, all calls fail with an exception trying to read the response. The calls do come through, but the response cannot be read. This is very likely because Httpclient 5.6 has built-in support for decompression, while Firebase performs its own decompression. This probably causes the data to be decompressed twice.

Exception in thread "main" com.google.firebase.messaging.FirebaseMessagingException: Unknown error while making a remote service call: Not in GZIP format
	at com.google.firebase.messaging.FirebaseMessagingException.withMessagingErrorCode(FirebaseMessagingException.java:51)
	at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:293)
	at com.google.firebase.messaging.FirebaseMessagingClientImpl$MessagingErrorHandler.createException(FirebaseMessagingClientImpl.java:282)
	at com.google.firebase.internal.AbstractHttpErrorHandler.handleIOException(AbstractHttpErrorHandler.java:63)
	at com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:111)
	at com.google.firebase.internal.ErrorHandlingHttpClient.sendAndParse(ErrorHandlingHttpClient.java:72)
	at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendSingleRequest(FirebaseMessagingClientImpl.java:127)
	at com.google.firebase.messaging.FirebaseMessagingClientImpl.send(FirebaseMessagingClientImpl.java:113)
	at com.google.firebase.messaging.FirebaseMessaging$1.execute(FirebaseMessaging.java:142)
	at com.google.firebase.messaging.FirebaseMessaging$1.execute(FirebaseMessaging.java:139)
	at com.google.firebase.internal.CallableOperation.call(CallableOperation.java:36)
	at com.google.firebase.messaging.FirebaseMessaging.send(FirebaseMessaging.java:109)
	at com.google.firebase.messaging.FirebaseMessaging.send(FirebaseMessaging.java:91)
	at nl.topicus.GoogleFirebaseApp.pushToGoogle(GoogleFirebaseApp.java:110)
	at nl.topicus.GoogleFirebaseApp.main(GoogleFirebaseApp.java:79)
Caused by: java.util.zip.ZipException: Not in GZIP format
	at java.base/java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:197)
	at java.base/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:81)
	at java.base/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:112)
	at com.google.api.client.http.GzipSupport.newGzipInputStream(GzipSupport.java:13)
	at com.google.api.client.http.HttpResponse.getContent(HttpResponse.java:364)
	at com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:101)
	... 10 more

Activity

  1. marksulls commented on Feb 3, 2026

    @marksulls

    I am getting the same issue. I copied the default HttpClient / HttpTransport configuration out of the ApiClientUtils.getDefaultTransport() method and then added disableContentCompression() to the HttpAsyncClientBuilder. This seems to fix the issue, although I only tested it on creating tenants.

    PoolingAsyncClientConnectionManager connectionManager =
                    PoolingAsyncClientConnectionManagerBuilder.create()
                            // Set Max total connections to match google api client limits
                            // https://github.com/googleapis/google-http-java-client/blob/f9d4e15bd3c784b1fd3b0f3468000a91c6f79715/google-http-client-apache-v5/src/main/java/com/google/api/client/http/apache/v5/Apache5HttpTransport.java#L151
                            .setMaxConnTotal(200)
                            // Set max connections per route to match the concurrent stream limit of the FCM backend.
                            .setMaxConnPerRoute(100)
                            .setDefaultConnectionConfig(
                                    ConnectionConfig.custom().setTimeToLive(-1, TimeUnit.MILLISECONDS).build())
                            .setDefaultTlsConfig(
                                    TlsConfig.custom().setVersionPolicy(HttpVersionPolicy.NEGOTIATE).build())
                            .setTlsStrategy(ClientTlsStrategyBuilder.create()
                                    .setSslContext(SSLContexts.createSystemDefault())
                                    .build())
                            .build();
    
            var client = HttpAsyncClientBuilder.create()
                    // Set maxConcurrentStreams to 100 to match the concurrent stream limit of the FCM backend.
                    .setH2Config(H2Config.custom().setMaxConcurrentStreams(100).build())
                    .setHttp1Config(Http1Config.DEFAULT)
                    .setConnectionManager(connectionManager)
                    .setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
                    .disableRedirectHandling()
                    // disable gzip encoding to work around https://github.com/firebase/firebase-admin-java/issues/1173
                    .disableContentCompression()
                    .disableAutomaticRetries();
    
            // configure the firebase client
            FirebaseOptions options = FirebaseOptions.builder()
                    // set the http transport
                    .setHttpTransport(new ApacheHttp2Transport(client.build()))
    
           ...
    

    I am not suggesting this is the best way to fix this, but it at least seems to confirm @papegaaij assumption about the cause. Downgrading to version 9.6.0 also works...

  2. jonathanedey commented on Feb 3, 2026

    @jonathanedey
    Contributor

    Hey folks, thanks for flagging this. We are looking into this issue and can confirm the double compression happening here.

    For now developers wanting to use Apache HttpClient 5.6+, similar to what @marksulls said, we recommend applying the disableContentCompression() method to your default or custom clients.

    HttpAsyncClientBuilder builder = ApacheHttp2Transport.defaultHttpAsyncClientBuilder();
    CloseableHttpAsyncClient client = builder.disableContentCompression().build();
    HttpTransport transport = new ApacheHttp2Transport(client);
    FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder()
        .setHttpTransport(transport)
        .build());

    We'll update here once we have a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions