aws / aws-sdk-net-extensions-cognito

An extension library to assist in the Amazon Cognito User Pools authentication process
Apache License 2.0
102 stars 49 forks source link

A deadlock occurs with Android and C# when trying to create a provider with Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient #84

Closed DominusDRR closed 2 years ago

DominusDRR commented 2 years ago

Description

Hi.

I'm using the AWS Samples C# project named aws-cognito-dot-net-desktop-app as a reference:

https://github.com/aws-samples/aws-cognito-dot-net-desktop-app

The code of this project I am using it with C # and WPF and it works correctly (app for desktop PC).

Now, I'm doing the exact same thing but with Android and C# in Visual Studio.

When you want to register a user, the task called SignUpUser is executed, but when trying to create a provider with Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient the code remains frozen in that line (deadlock)

This is an image of where the problem happens:

image

No exception or error message occurs.

It happens both in a real mobile phone and in a virtual phone.

It is as if some permission or something else needs to be enabled, even though internet and wifi permissions are enabled in the manifest.

Reproduction Steps

  1. Create a project of type Xamarin (Not Xamarin Forms) with Visual Studio 2019

  2. Copy or create the CognitoHelper class in the project, it is the same as aws-cognito-dot-net-desktop-app.

  3. Do not forget to install all the packages that correspond to Amazon ()using Amazon.CognitoIdentity, using Amazon.S3.Model, etc)

  4. From another class you can invoke the task of registering a user as follows:

CognitoHelper helper = new CognitoHelper(); bool success = await helper.SignUpUser("UserName", "passwword", "userEmail@gmail", "123456789");

  1. The code remains in a deadlock in AmazonCognitoIdentityProviderClient provider = new Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials());.

Logs

Environment

Resolution

where to create a provider must be as follows: (Obviously the region must be correct)

AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), RegionEndpoint.YourRegionAWS)


This is a :bug: bug-report

ashishdhingra commented 2 years ago

Hi @DominusDRR,

Good morning.

Could you please advise on how your region is configured for your Xamarin app?

Thanks, Ashish

DominusDRR commented 2 years ago

Hi @DominusDRR,

Good morning.

Could you please advise on how your region is configured for your Xamarin app?

Thanks, Ashish

Hi. Thanks for writting.

It seems that I found a solution few minutes ago.

I got an example for Xamarin. Forms of this link:

https://github.com/Pietervdw/xamarinforms-awscognito

When reviewing the code and seeing how a provider is created, I changed the code to as follows:

Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient provider = new Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient(new AnonymousAWSCredentials(), RegionEndpoint.USEast1);

Now the code doesn't freeze and goes to the next line:

image

I need to keep going through the rest of the code to determine other possible issues

ashishdhingra commented 2 years ago

@DominusDRR Thanks for confirming. Changing this to guidance issue. Please close this issue once you are done scanning through rest of the code, OR, confirm if we could close this now since you have identified the solution.

DominusDRR commented 2 years ago

hanks for confirming. Changing this to guidance issue. Please close this issue once you are done scanning through rest of the code, OR, confirm if we could close this now since you have identified the solution.

Hi.

Confirmed, where to create a provider must be as follows: (Obviously the region must be correct)

AmazonCognitoIdentityProviderClient(new Amazon.Runtime.AnonymousAWSCredentials(), RegionEndpoint.YourRegionAWS;

Process to close the case. Thanks again.

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.