-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amplify Storage put fails to upload after an hour with session token expiry #13347
Comments
hello @vinu-ablabs . Sorry for any inconvenience with the library. Is it possible for you to upgrade to v6, and test this behavior ? You can decrease the expiration time of your access token to 5 minutes for faster testing. |
The issue is not with cognito access token. Upgrading would need us to
migrate some of the code. This was a production. What is expiring is the
session token from sts
Thanks and Regards,
Vineeth Vijayan
+91 9902921500
*Head of Engineering*
…On Wed, 8 May 2024 at 21:58, israx ***@***.***> wrote:
hello @vinu-ablabs <https://github.com/vinu-ablabs> . Sorry for any
inconvenience with the library. Is it possible for you to upgrade to v6,
and test this behavior ? You can decrease the expiration time of your
access token to 5 minutes for faster testing.
—
Reply to this email directly, view it on GitHub
<#13347 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A2DSXOCF45CLD3A4QDVWS6TZBJHBFAVCNFSM6AAAAABHMKTABCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBQHE2TMOBTGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thank you for the context. I'll bring this to the team, try to reproduce it and be back with next steps. Thanks for the patience! |
Related to #13307 |
hello @vinu-ablabs . Are you seeing this error after authenticating via a social provider, username and password, guess access or all of them ? |
hey @vinu-ablabs . Is this issue also happening for both light and heavy size files ? |
@israx Yes. Even any API calls going through Amplify prior to the upload calls do not revive the session |
@israx Yes it happens to login via email/password. I believe it could happen to all of them |
Hello @vinu-ablabs . I'm unable to reliable reproduce this issue. I see the library is able to refresh tokens and credentials on the following scenarios:
In both cases the library is constantly refreshing AWS credentials and authentication tokens. Can you upgrade to the latest version of |
HI @israx Tried with 5.3.18 but still no luck Getting the below error still ResponseRequest URL: Request HeadersPUT /public/vendor/xxxxx-2636-4737-b2a4-xxxx/bid-attachments/19fff378-1f09-4674-a0fc-xxxx/version0/d211fbe1-772b-4a42-8a3b-xxxxx.png HTTP/1.1 Response headersHTTP/1.1 400 Bad Request |
That issue is related to creds being expired while uploading a heavy file, and we currently have a PR to address it. We highly recommend to upgrade to v6 as we are constantly bringing updates. |
@israx I have a feeling that the same thing is happening here as well. When you do not use the S3 APIs for an hour, the credentials expire, and the signed URL won't work after that. I can see the credentials (Cognito) are refreshing, but I don't think that is being used here. Upgrading to v6 at this juncture would require us to do a through round of testing As a workaround, I am moving away from the storage plugin and getting a presigned url from the backend to upload the file. I will let you know how that goes |
Thanks @vinu-ablabs for all the context. We will dig deep into the root cause in v5 and follow up with next steps. Thanks for the patience |
hello @vinu-ablabs . In the mean time can you try the following setting in your config and see if that ends up working for you?
|
@israx That didnt work. Still getting the error |
hey @vinu-ablabs . Following up on the issue. You are mentioning that after 1 hour even the preSigned URL won't work. This is expected behavior as credentials have a default expiration of 50 minutes. A potential work around is to refetch the preSigned URL on an interval or just manually increasing the expiration date. What I'm still not able to repro is the failing calls to the |
@israx When i said presignedUrl, I didnt mean the url you fetched via preSIgnedUrl method. From what I understood/assume is assumed, the sdk signs the put url with a credentials which expires like you mentioned. Once it fails its not really refreshing the url/credentials and further attempts to upload fails. It works once you refresh the whole screen and the library reinitializes. The repo we have is tied to the company. Will see if we can reproduce the issue on a barebone repo and share it with you. Might take some time to do that |
hey @vinu-ablabs . The way am testing and not able to reproduce this issue is by doing the following:
Something that might be happening is that your If that is not an issue, then something that can help is to provide a sample app or more specific steps to reliable reproduce the issue. |
btw this issue is v6 specific and it happens only when creds and tokens are expired while uploading a file. If you do the same on v5 the library will refresh tokens and creds on demand while the file is being uploaded. |
Hi @vinu-ablabs, |
@vinu-ablabs, going to close this issue at this point since we have not heard back. If you have more details on how to reproduce this issue in a consistent way on v5 or have a minimal sample app that can be shared, let us know! For anyone else that comes across this issue, we have not been able to reproduce on v5 and there are no problems in v6 when uploading items. |
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Storage
Amplify Version
v5
Amplify Categories
storage
Backend
None
Environment information
Describe the bug
We use amplify with Cognito and have some user uploaded files pushed to S3. Both both reactJs webapp and react native mobile app do similar functions.
If the user leaves the screen unattended for more than an hour, further invocation of Strorage.Put keeps failing, saying the session token has expired. It resumes working only after refreshing the page. We checked the amplify-user in IAM console and it is configured to have access keys
It looks like Amplify signs the S3 URL and does not refresh the token even after the session expires. Ideally, since it is a key based signature, the token is an optional parameter. All further attempts give the same error and the session error. Initially we thought it to be a cognito token expiry but turns out that is not relevant here
Expected behavior
Ideally, the token should refresh if it fails and a new signed url should be created. If not we need to do this at our backend servers and push the new signed url to front end. Trying to avoid this.
Reproduction steps
Use amplify Storage in any reactJs app
leave the app idle for an hour
Try uploading a file
Code Snippet
Log output
aws-exports.js
Manual configuration
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: