microsoft / PowerPlatform-DataverseServiceClient

Code Replica for Microsoft.PowerPlatform.Dataverse.Client and supporting nuget packages.
MIT License
280 stars 51 forks source link

The request was cancelled due to the configured httpclient.timeout of 100 seconds elapsing #464

Open bipinshan opened 2 months ago

bipinshan commented 2 months ago

Dot NET Core 8.0 Windows BackgroundService C#

Microsft.PowerPlatform.Dataverse.Client Latest version

Connection String - Auth Type = OAuth I am using sample App Id provided by Microsoft https://learn.microsoft.com/en-us/power-apps/developer/data-platform/xrm-tooling/use-connection-strings-xrm-tooling-connect#create-a-connection-string

Hosted on Private Cloud Foundry (PCF)

Failed to connect to Dataverse: The request was cancelled due to the configured httpclient.timeout of 100 seconds elapsing

Error Requesting Access Token

Dependency Injection is not used in my sample code.

Please help us to troubleshoot and fix this issue.

I have tried using http://localhost for RedirectUril property but getting same error.

Note - code works fine when I execute from my machine on VS 2022

I tried passing ILogger to log detailed error but no help.

MattB-msft commented 2 months ago

Hi @bipinshan, You cannot use oAuth + Background services unless you configure authprompt=never and pass the password. background services cannot present a user interaction dialog.

You will either need to use AuthType ClientSecret or ClientCertificate to connect to dataverse from a non-interactive service.

bipinshan commented 2 months ago

Hi @MattB-msft ,

Thank you for replying to my query.

I did use authprompt=never and passing password in connection String but I am still seeing the same error.

MattB-msft commented 2 months ago

I suspect your tenant is forcing multi factor authentication. Can you try with an application user ?


From: BIPIN @.> Sent: Thursday, August 29, 2024 8:01:03 PM To: microsoft/PowerPlatform-DataverseServiceClient @.> Cc: Mention @.>; Comment @.>; Subscribed @.***> Subject: Re: [microsoft/PowerPlatform-DataverseServiceClient] The request was cancelled due to the configured httpclient.timeout of 100 seconds elapsing (Issue #464)

Hi @MattB-msfthttps://github.com/MattB-msft ,

Thank you for replying to my query.

I did use authprompt=never and passing password in connection String but I am still seeing the same error.

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/PowerPlatform-DataverseServiceClient/issues/464#issuecomment-2319770075 or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACQUENESWQLK6XGUXDGPRF3ZT7N67BFKMF2HI4TJMJ2XIZLTSOBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLLDTOVRGUZLDORPXI6LQMWWES43TOVSUG33NNVSW45FGORXXA2LDOOJIFJDUPFYGLKTSMVYG643JORXXE6NFOZQWY5LFVEZDINJQGM3TAMZUQKSHI6LQMWSWS43TOVS2K5TBNR2WLKRSGQ4TKMJXGIZDCNNHORZGSZ3HMVZKMY3SMVQXIZI. You are receiving this email because you were mentioned.

Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

bipinshan commented 2 months ago

Hi @MattB-msft ,

I am in the process of provisioning an application user. I will try and let you the outcome.

bipinshan commented 1 month ago

Hi @MattB-msft , So I tried clientsecret auth type today and it failed with the same error.

Error Requesting token

Any idea why it is failing?

MattB-msft commented 1 month ago

Sorry for the delay in responding. in this case, You should make sure your logging out the trace log from the client and have added "MSALLogPII" true in your appconfig , or set it as part of your constructor. That will help provide the full stack trace of what is going on with the MSAL auth flow.

Alternatively you can set up a standalone project to create an authentication token for the remote service and use that to debug the issue. To do that, You would utilize the samples and doc's from the MSAL.net git hub to setup that sample. You can find an example of that here: https://learn.microsoft.com/entra/msal/dotnet/getting-started/instantiate-confidential-client-config-options

bjm3819 commented 3 weeks ago

Were having a similar error message but related to proxy..

Were using ServiceClient in a web app. The web app lives in a EC2. The company uses a proxy. I also have a .net core console app, this app on the same EC2 can get out to the dataverse/dynamics endpoint when setting the env http proxy variables. However, the web site cannot, it's httpclient connection under the hood of the ServiceClient type times out.

What can we do? Were using a Amazon Linux 2023.3.20240312 and have also tried Red Hat Enterprise Linux 8.10 (Ootpa)