question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

More Flexible VersionPolicy

See original GitHub issue

New Feature

Configurable HttpRequestMessage.VersionPolicy.

Motivation for New Feature

The following setup:

  • an MVC ASP.NET Core as frontend.
  • Ocelot gateway
  • some microservices

All components above configured to use Kestrel with the following snippet:

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(opts =>
{
    opts.ConfigureEndpointDefaults(lopts =>
    {
        lopts.Protocols = HttpProtocols.Http2;
    });
});

All components above should only talk to each other using HTTP/2 and no TLS (plain HTTP).

User Scenario

With plain Ocelot 18.0.0, I couldn’t make them talk to each other with plain HTTP from frontend to the service. The services will print out error messages like the following:

HTTP/2 connection error (PROTOCOL_ERROR): Invalid HTTP/2 connection preface

Solution

Found out that I need to make sure that HttpRequestMessage has its VersionPolicy to be set RequestVersionOrHigher.

Changes I made

  • namespace: Ocelot.Request.Mapper class: RequestMapper method: Task<Response<HttpRequestMessage>> Map(HttpRequest request, DownstreamRoute downstreamRoute) changes:
    • added VersionPolicy = HttpVersionPolicy.RequestVersionOrHigher, in HttpRequestMessage instantiation.
  • namespace: Ocelot.Requester class: HttpClientBuilder method: IHttpClient Create(DownstreamRoute downstreamRoute) changes:
    • added DefaultRequestVersion = downstreamRoute.DownstreamHttpVersion, and DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher, in HttpClient instantiation.

Then all those components above can talk to each other in HTTP/2.

And I think DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher could be DefaultVersionPolicy downstreamRoute.DownstreamHttpVersionPolicy.

And I am willing to make a PR if you fine folks think this kind of changes is welcome.

Specifications

  • Version: 18.0.0
  • Platform: ASP.NET Core 6.0
  • Subsystem: ASP.NET 6.0 Docker image. Should be Debian, yes?

Issue Analytics

  • State:open
  • Created 3 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ibnudacommented, Jun 30, 2023

sorry, i closed this issue because i thought we reached an agreement that:

  • this feature is welcome
  • i will make a pr for this feature
  • i will base the pr on develop branch.
  • there’s no need to backport this feature to v18 branch.

personally, i don’t mind using the latest version of Ocelot.

and re-opening this issue.

0reactions
raman-mcommented, Jun 30, 2023
+ Accepted

A solution is ready in PR #1673

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Database for PostgreSQL versioning policy
Describes the policy around Postgres major and minor versions in Azure Database for PostgreSQL - Single Server.
Read more >
Flex APIs Version Policy
We aim to please everybody with a versioning scheme for the Flex APIs that offers both a dependable format as well as incremental...
Read more >
Supported versions - Azure Database for PostgreSQL
Describes the supported PostgreSQL major and minor versions in Azure Database for PostgreSQL - Flexible Server.
Read more >
azure-docs/articles/mysql/concepts-version-policy.md at main
Version support policy - Azure Database for MySQL - Single Server and Flexible Server. Describes the policy around MySQL major and minor versions...
Read more >
More flexible version attribute · Issue #27
Replace the version/docversion/pkgversion attributes with a single version attribute that can take a space-separated list of version tokens.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found