Skip to content
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

Add support for using HTTP/2 & possibly HTTP/3 as well instead of only HTTP/1.1 #2674

Open
Eagle3386 opened this issue Sep 20, 2024 · 4 comments
Labels

Comments

@Eagle3386
Copy link

Is your feature request related to a problem? Please describe the problem.

AFAICT, the GraphServiceClient uses HTTP/1.1 & there's no chance of instructing it to use HTTP/2 (or even HTTP/3) instead - at least not without rewriting basically half of the client.

Describe the solution you'd like.

Please allow configuration of the HTTP version used, preferably by providing an optional argument that's passed down to the HttpClientHandler's HttpVersion & defaulting to HTTP/1.1.

Additional context?

No response

@Eagle3386 Eagle3386 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:feature New experience request labels Sep 20, 2024
@andrueastman
Copy link
Member

Thanks for raising this @Eagle3386

I believe the latest version of the SDK should be making HTTP/2 requests and downgrading the same in the scenario where is not supported.

See https://github.com/microsoft/kiota-dotnet/blob/427e3ff3c7517f68d395e1591be127f29803f7c8/src/http/httpClient/HttpClientRequestAdapter.cs#L625

Any chance you can confirm if you are seeing something different from your end?

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Sep 23, 2024
@Eagle3386
Copy link
Author

Eagle3386 commented Sep 25, 2024

@andrueastman sure, there you go:
{18CEC2C6-8DBB-4B4A-BDD9-66CCB7366BE4}

NuGet-Packages are Microsoft.Identity.Web.GraphServiceClient (version 3.1.0) which has a transient dependency on Microsoft.Graph (version 5.40.0).
As the screenshot above shows, the Graph endpoint used is version 1.0.

Despite setting several items to logging level Debug (including Default) via AppSettings[.Development].json, I can't see any output of the GraphServiceClient in VS - neither in the integrated terminal nor the output window.
Do you have any suggestions for how to get further debug details showing up?

The GraphServiceClient is setup like this in Program.cs:

// … code left out for brevity…
var configuration   = builder.Configuration;
var isNonProduction = !builder.Environment.IsProduction();
// … code left out for brevity…
.AddAuthentication()
.AddMicrosoftIdentityWebApi(options =>
  {
    LogCompleteSecurityArtifact = ShowPII = isNonProduction;
    configuration.Bind(Constants.AzureAdB2C, options);
    options.TokenValidationParameters = new()
    {
      // … code left out for brevity…
      LogValidationExceptions = false
    };
  },
  options => configuration.Bind(Constants.AzureAdB2C, options),
  subscribeToJwtBearerMiddlewareDiagnosticsEvents: isNonProduction)
.EnableTokenAcquisitionToCallDownstreamApi(options =>
{
  // … code left out for brevity…
  options.EnablePiiLogging = isNonProduction;
  options.LogLevel         = isNonProduction ? LogLevel.Always : LogLevel.Info;
})
.AddMicrosoftGraphAppOnly(_ =>
  new(
    new Azure.Identity.ClientSecretCredential(
      configuration[$"{Constants.AzureAdB2C}:{nameof(MicrosoftIdentityOptions.TenantId)}"],
      clientId,
      clientSecret,
      new()
      {
        Diagnostics =
        {
          IsAccountIdentifierLoggingEnabled = isNonProduction,
          IsDistributedTracingEnabled       = isNonProduction,
          IsLoggingContentEnabled           = isNonProduction,
          IsLoggingEnabled                  = isNonProduction,
          IsTelemetryEnabled                = isNonProduction
        },
        IsUnsafeSupportLoggingEnabled = isNonProduction
      })))
.AddInMemoryTokenCaches(options =>
  options.AbsoluteExpirationRelativeToNow = TimeSpan.FromDays(isNonProduction ? 14 : 90)) // 14 = Default
// … code left out for brevity…

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Sep 25, 2024
@andrueastman
Copy link
Member

Thanks for getting back @Eagle3386

I believe the screenshot you as showing is the HttpClient property here https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.defaultrequestversion?view=net-8.0.. This doesn't apply to the SDK as the SDK makes calls using the SendAsync method9see remarks in the docs).

The SDK however by default creates HttpRequestMessage instance with the version set to 2.0 as seen at https://github.com/microsoft/kiota-dotnet/blob/427e3ff3c7517f68d395e1591be127f29803f7c8/src/http/httpClient/HttpClientRequestAdapter.cs#L625

Any chance you can try using the guidance at the link below to use the instrumentation in HttpClient to see what requests are made?
https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/blob/main/docs/logging-requests.md#b-take-advantage-of-opentelemetrys-instrumentation-of-httpclient

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Sep 25, 2024
@Eagle3386
Copy link
Author

@andrueastman That's not really helpful, because although I

  • added both packages,
  • worked around the outdated docs (theres no Enrichproperty, but multipleEnrich*` ones to start with)
  • even tried the using var tracerProvider = OpenTelemetry.Sdk (…) .Build(); snippet in both, my service's Program.cs file & also directly within the corresponding service's method

there's simply no log visible anywhere.

I expected (almost) "copy & paste"-ready instructions, so I can finally show that the SDK doesn't work as advertised (or does & I'm simply blind). Yet, I'm dealing with cumbersome steps to even get debug logs going - almost a nightmare of a developer experience, I've got to admit.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants