GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Storage - SocketException Socket closed (gcloud java 0.28) · Issue #1227 · googleapis/google-cloud-java

Storage - SocketException Socket closed (gcloud java 0.28) #1227

New issue
Copy link
New issue
Copy link
Closed
#1233
Closed
Storage - SocketException Socket closed (gcloud java 0.28)#1227
#1233
Copy link
Assignees
mziccard
Labels
api: storageIssues related to the Cloud Storage API.

Description

@fondberg
fondberg
opened on Sep 7, 2016
Issue body actions

We still see StorageException caused by SocketExceptions even if they should have been retried.

java.net.SocketException: Socket is closed
    at sun.security.ssl.SSLSocketImpl.getInputStream
    at sun.net.www.http.HttpClient.parseHTTP
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream
    at java.net.HttpURLConnection.getResponseCode
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode
    at com.google.api.client.http.javanet.NetHttpResponse.<init>
    at com.google.api.client.http.javanet.NetHttpRequest.execute
    at com.google.api.client.http.HttpRequest.execute
    at com.google.cloud.storage.spi.DefaultStorageRpc.open
    at com.google.cloud.storage.BlobWriteChannel.<init>
    at com.google.cloud.storage.StorageImpl.writer
    at com.google.cloud.storage.StorageImpl.writer
    at com.google.cloud.storage.StorageImpl.writer
    at com.spotify.buildartifactarchiver.storage.GcsUploaderClient.storeInputStream
    at com.spotify.buildartifactarchiver.storage.ArtifactUploader.uploadZipArchive
    at com.spotify.buildartifactarchiver.storage.ArtifactUploader.upload
    at com.spotify.buildartifactarchiver.ArtifactArchiver.archiveArtifactsForBuild
    at com.spotify.buildartifactarchiver.ArtifactArchiver.archiveBuild
    at com.spotify.buildartifactarchiver.web.ArtifactArchiverPubSubResource.messageHandler
    at com.spotify.google.cloud.pubsub.client.Puller.lambda$pullBatch$11
    at java.util.concurrent.CompletableFuture.uniWhenComplete
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire
    at java.util.concurrent.CompletableFuture.postComplete
    at java.util.concurrent.CompletableFuture.complete
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.succeed
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.lambda$wrap$9
    at java.util.concurrent.CompletableFuture.uniWhenComplete
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire
    at java.util.concurrent.CompletableFuture.postComplete
    at java.util.concurrent.CompletableFuture.complete
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.succeed
    at com.spotify.google.cloud.pubsub.client.Pubsub.lambda$requestJavaNet$8
    at java.util.concurrent.ThreadPoolExecutor.runWorker
    at java.util.concurrent.ThreadPoolExecutor$Worker.run
    at java.lang.Thread.run
com.google.cloud.storage.StorageException: Socket is closed
    at com.google.cloud.storage.spi.DefaultStorageRpc.translate
    at com.google.cloud.storage.spi.DefaultStorageRpc.open
    at com.google.cloud.storage.BlobWriteChannel.<init>
    at com.google.cloud.storage.StorageImpl.writer
    at com.google.cloud.storage.StorageImpl.writer
    at com.google.cloud.storage.StorageImpl.writer
    at com.spotify.buildartifactarchiver.storage.GcsUploaderClient.storeInputStream
    at com.spotify.buildartifactarchiver.storage.ArtifactUploader.uploadZipArchive
    at com.spotify.buildartifactarchiver.storage.ArtifactUploader.upload
    at com.spotify.buildartifactarchiver.ArtifactArchiver.archiveArtifactsForBuild
    at com.spotify.buildartifactarchiver.ArtifactArchiver.archiveBuild
    at com.spotify.buildartifactarchiver.web.ArtifactArchiverPubSubResource.messageHandler
    at com.spotify.google.cloud.pubsub.client.Puller.lambda$pullBatch$11
    at java.util.concurrent.CompletableFuture.uniWhenComplete
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire
    at java.util.concurrent.CompletableFuture.postComplete
    at java.util.concurrent.CompletableFuture.complete
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.succeed
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.lambda$wrap$9
    at java.util.concurrent.CompletableFuture.uniWhenComplete
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire
    at java.util.concurrent.CompletableFuture.postComplete
    at java.util.concurrent.CompletableFuture.complete
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.succeed
    at com.spotify.google.cloud.pubsub.client.Pubsub.lambda$requestJavaNet$8
    at java.util.concurrent.ThreadPoolExecutor.runWorker
    at java.util.concurrent.ThreadPoolExecutor$Worker.run
    at java.lang.Thread.run

We are uploading files using the following code if there is something that we might be doing wrong...

  public void storeInputStream(InputStream input, String fileName, String contentType)
      throws IOException {

    Storage storage = getStorage();

    BlobId blobId = BlobId.of(this.bucketName, fileName);
    LOG.debug("blobId: {}", blobId);
    BlobInfo blobInfo = BlobInfo.builder(blobId).contentType(contentType).build();
    LOG.debug("blobInfo: {}", blobInfo);
    LOG.info("Starting upload to GCS for file: {} with content type:{}", fileName, contentType);
    //perform stream uploads of the InputStream
    try (WriteChannel writer = storage.writer(blobInfo)) {
      byte[] buffer = new byte[1024];
      int limit;
      while ((limit = input.read(buffer)) >= 0) {
        writer.write(ByteBuffer.wrap(buffer, 0, limit));
      }
    }
  }

Activity

  1. mziccard commented on Sep 7, 2016

    @mziccard
    mziccard
    on Sep 7, 2016
    Contributor
    More actions

    Hi @fonzy2013,

    this is odd but I might have an answer.

    What is odd:

    • You are getting java.net.SocketException: Socket is closed when opening a resumable session, not when uploading data. This is odd as calls to open do not carry a lot of data with them (few bytes) and should therefore be less susceptible to timeouts/network disruptions (or whatever it is that is causing this weird exception) while in progress.

    Why this is happening:

    • Calls to open in WriteChannel are not retried, not sure why

    Good news:

    • I can fix this right away by adding our retry logic to open calls in WriteChannel

    I am sorry you are experiencing these issues, and I thank you for reporting them.

  2. mziccard
    added
    api: storageIssues related to the Cloud Storage API.
    on Sep 7, 2016
  3. fondberg commented on Sep 7, 2016

    @fondberg
    fondberg
    on Sep 7, 2016
    Author
    More actions

    @mziccard Thanks for speedy and great advice/support!
    Strange indeed. Might it be a network related socket closure?

    Now we are in production and only after 3 hours I saw around 150 exceptions (around 1-2% failure rate) which isn't all that bad but still ;-)

  4. mziccard commented on Sep 7, 2016

    @mziccard
    mziccard
    on Sep 7, 2016
    Contributor
    More actions

    around 1-2% failure rate

    All these exceptions originate from a SocketException Socket closed exception with com.google.cloud.storage.spi.DefaultStorageRpc.open in the stacktrace? @Capstan what do you think about this failure rate?

    Once again, adding retryals will mitigate this issue, I'll draft a PR ASAP.

  5. mziccard
    closed this as completedin #1233on Sep 9, 2016
  6. JustinBeckwith
    assigned
    mziccard
    on Feb 1, 2021
  7. github-actions
    added a commit that references this issue on Jul 1, 2022

    chore(main): release 3.4.0 (googleapis#1232)

    856ea8c
  8. github-actions
    added a commit that references this issue on Aug 25, 2022

    chore(deps): update dependency com.google.cloud:google-cloud-automl t…

    40bd1cf
  9. meltsufin
    added a commit that references this issue on Dec 22, 2025

    chore(deps): update dependency com.google.cloud:google-cloud-logging …

    1ae01f9
  10. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore(main): release 2.17.5 (#1227)

    64a3a22
  11. chingor13
    added a commit that references this issue on Feb 24, 2026

    chore: Java 8 unit test to build code in Java 17 and run tests on Jav…

    a684040
  12. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore(deps): update dependency com.google.cloud:google-cloud-logging …

    bd85208
  13. chingor13
    added a commit that references this issue on Mar 12, 2026

    chore: Java 8 unit test to build code in Java 17 and run tests on Jav…

    38fa4f6
  14. suztomo
    added a commit that references this issue on Mar 23, 2026

    deps: update dependency com.google.cloud:google-cloud-shared-dependen…

    e9ab094
  15. suztomo
    added a commit that references this issue on Mar 30, 2026

    chore(main): release 0.127.1-SNAPSHOT (#1227)

    572c422
  16. lqiu96
    added a commit that references this issue on Apr 1, 2026

    chore(main): release 0.127.1-SNAPSHOT (#1227)

    58d563b
  17. meltsufin
    added 4 commits that reference this issue on Apr 29, 2026

    deps: update dependency com.google.cloud:google-cloud-core to v2.8.7 (#…

    e967b2c

    chore(main): release 1.120.9 (#1228)

    694f0f3

    deps: update dependency com.google.cloud:google-cloud-core to v2.8.7 (#…

    52fe226

    chore(main): release 1.120.9 (#1228)

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

Metadata

Metadata

Assignees

  • @mziccard
    mziccard

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.