-
Notifications
You must be signed in to change notification settings - Fork 289
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
Connection Timeout issue when trying to execute Non Async method using Dapper, Microsoft.Data.SqlClient V3.0.0 Stable in .NETFrameowork 4.8 WebApplication #1138
Comments
@somnath-pramanik123 base on the part of the code you posted you are using MARS enabled in your connection string. Is that correct? Can you send your connection string as well please (Please do not send any sensitive information such as password)? Thank you. |
@JRahnama,
|
@somnath-pramanik123 Can you test your application by setting the |
@JRahnama : Tried with TrustServerCertificate=True and increasing ConnectionTimeout value..but no luck. Did you try with the set up I mentioned and is it working on your end?. If yes, can you share the code. |
@somnath-pramanik123 let's check if the token is acquired from MSAL library. Can you run the application on this gist. Do not forget to provide your server name at line 22 |
Dear All, We are trying to get the access token to use to request my own api. I am using Microsoft. Identity.Client nuget. version: 4.36.0 a) In Net core MVC web application, unit test, console , Library projects works. c) In MVC web application with net framework 4.7.2 do not work. When you execute await app.AcquireTokenForClient(scopes) . It stay forever not response. We did the following. you can replicate the problem. Open visual studio 2019. Create a new project using MVC web application net framework 4.7.2 Inside the home controller add the following code: public async Task<string> TokenGetAsync()
{
IConfidentialClientApplication app;
app = ConfidentialClientApplicationBuilder.Create(" your AD client ID ")
.WithClientSecret(" Secret ID ")
.WithAuthority(new Uri("https://login.microsoftonline.com/ {domain name} .onmicrosoft.com"))
.Build();
string[] scopes = new string[] { "https://{domain name}.onmicrosoft.com/xxxxxx/.default" };
AuthenticationResult result = null;
try
{
// **************Here stay for ever never return the token in MVC net framework 4.7.2******************
result = await app.AcquireTokenForClient(scopes)
.ExecuteAsync();
}
catch (MsalServiceException ex) when (ex.Message.Contains("AADSTS70011"))
{
Console.WriteLine("Scope provided is not supported");
return "";
}
return result.AccessToken;
}
public ActionResult Index()
{
ViewBag.Token = TokenGetAsync().GetAwaiter().GetResult();
return View();
} |
@smartstoremx can open a new issue for this matter. It will make it easier for others to follow the problem in a related context and also will not mix this issue with any other issue. In that issue please mention if you are using System.Data.SqlClient or Microsoft.Data.SqlClient and what version of them. |
@smartstoremx plus at this part of your code Microsoft.Data.SqlClient nor System.Data.SqlClient is involved. you are using either using ADAL or MSAL library to acquire token. I think the setup is explained in here. For more information you can open an issue with related group. |
The issue you posted was discussed here:
It was fixed in PR #1213 so please try with latest v4.0.0-preview1+ and it should be resolved. I will close this issue as the original issue was fixed with this PR too. |
Describe the bug
A clear and concise description of what the bug is.
Getting timeout issue while trying to execute Non Async method using Dapper and Microsoft.Data.SqlClient,.
The text was updated successfully, but these errors were encountered: