microsoft / azure-spring-boot

Spring Boot Starters for Azure services
MIT License
374 stars 460 forks source link

Connection reset by peer at random by using azure-storage-spring-boot-starter #855

Closed romlod closed 3 years ago

romlod commented 4 years ago

Hi,

We are using the azure-storage-spring-boot-starter for downloading blobs from the blob storage. It works fine, but every now and then we get the following error: Failed to download file from blob https://<<location>>/file.png to <<location>>. Reason is: Status code 403, (empty body).

After getting the stackTrace we also see this:

failed: Connection reset by peer

Our code is quite simple and have no idea why this happens. Is this due to a timeout or just a bug in the old library that is being used in this starter? If we restart the API then it works again. Then after some time it happens again.

We don't see any possibility to at a timeout or whatsoever. See snippet below:


        AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(Paths.get(destinationFile.getAbsolutePath()), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
        TransferManager.downloadBlobToFile(fileChannel, blockBlobURL, null, null)
                .doOnSuccess(headers -> {
                    log.info("File is downloaded to {}.", destinationFile);
                    downloadSuccess.set(true);
                })
                .doOnError(error -> handleDownloadBlobError(fileChannel, blobFileName, blockBlobURL, destinationFile, error))
                .blockingGet();

Thanks. Romario

saragluna commented 4 years ago

Thanks for reaching out. Which version of the storage starter are you using?

anumalasri commented 4 years ago

We are also experiencing same issue with below stack trace Using azure-storage-spring-boot-starter v2.2.2 and with Azure Storage Resource of StorageV2 (general purpose v2)

java.lang.RuntimeException: java.util.concurrent.TimeoutException: The source did not signal an event for 60 seconds and has been terminated.
    at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46) ~[rxjava-2.2.18.jar!/:?]
    at io.reactivex.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:93) ~[rxjava-2.2.18.jar!/:?]
    at io.reactivex.Single.blockingGet(Single.java:2870) ~[rxjava-2.2.18.jar!/:?] 
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
Caused by: java.util.concurrent.TimeoutException: The source did not signal an event for 60 seconds and has been terminated.
    at io.reactivex.internal.operators.single.SingleTimeout$TimeoutMainObserver.run(SingleTimeout.java:123) ~[rxjava-2.2.18.jar!/:?]
    at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38) ~[rxjava-2.2.18.jar!/:?]
    at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26) ~[rxjava-2.2.18.jar!/:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_242]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_242]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_242]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_242]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_242]

Is there any fix or workaround for this issue ?

yiliuTo commented 4 years ago

Hi, the azure-storage-blob dependency that this azure-storage-spring-boot-starter refers to is too old. You can update it to a higher version to see if the problem still exists, for example, add the following dependency in pom.xml :

  <groupId>com.azure</groupId>
  <artifactId>azure-storage-blob</artifactId>
  <version>12.6.0</version>  <!-- {x-version-update;com.azure:azure-storage-blob;dependency} -->

anumalasri commented 4 years ago

@yiliuTo .. Do you want us to add dependency com.azure:azure-storage-blob:12.6.0 along with azure-storage-spring-boot-starter ? Does both versions compatible each other? Please confirm.

If you are suggesting not to use azure-storage-spring-boot-starter, then we believe, its bigger discussion on the dependency update process.. Spring Boot starter has all configuration required for Spring Applications, where as other dependency required us to manage all those configuration. This process becomes very tedious due to limited documentation on Azure Java SDK.

Do you agree ?

yiliuTo commented 4 years ago

Hi, @anubhavranjan. Currently we are migrating the azure-spring-boot repo to azure-sdk-for-java, and during this process, azure-storage-spring-boot-starter will be deprecated but we will give a sample of how to use Azure Storage Blob. Thus we recommend that you can use the com.azure:azure-storage-blob dependency directly with a closer version instead of the starter.

anubhavranjan commented 4 years ago

@yiliuTo Did you mean to tag @anumalasri ?

yiliuTo commented 4 years ago

Sorry for my misoperation.

anumalasri commented 4 years ago

I already mentioned my comments on 'not using azure-storage-spring-boot-starter'.

Now we are hearing about deprecation of azure-storage-spring-boot-starter. However, we could see updates to latest Spring Boot v2.2.4.

@yiliuTo We find any traces about deprecation, you mentioned. Is this deprecation only for Storage or all other components ? Where can we find more details and plan for deprecation?

Does this deprecation reflecting in Spring Initializr ?
image

jialindai commented 4 years ago

@anumalasri, thanks for the detailed feedbacks, I'd like to share some context / plan on the storage starter.

Currently there are two Spring starters for Azure Storage:

There is plan to combine them, which is deprecate azure-storage-spring-boot-starter and enhance spring-starter-azure-storage.

To mitigate the impact, we will provide one sample to show how to do what azure-storage-spring-boot-starter provides: inject storage sdk's entry object into Spring application context.

Please note the sample will be based on Azure Storage track 2 library, and the entry objects has changed.

yiliuTo commented 4 years ago

For the sample project about using Azure Blob storage with Spring Boot, you can refer to this.

chenrujun commented 3 years ago

Closing this issue. Because it's not active for a long time. If anyone have similar issue, please create issue in new repo: https://github.com/Azure/azure-sdk-for-java/issues