From 7a6776a1e870dc61783288b194854c7657bbb2f9 Mon Sep 17 00:00:00 2001 From: vc-ci Date: Mon, 4 Mar 2024 14:11:20 +0000 Subject: [PATCH 1/2] 6.41.0 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index ce9247aa..94c03f9c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,7 +7,7 @@ VirtoCommerce - 6.40.0 + 6.41.0 $(VersionSuffix)-$(BuildNumber) From ab97932fb9a17bd678e82c9a032b72b2582e9e3e Mon Sep 17 00:00:00 2001 From: Aleksandr Vishniakov Date: Tue, 26 Mar 2024 10:10:47 +0200 Subject: [PATCH 2/2] VCST-206: Proxy XAPI subscription websocket connections (#676) --- VirtoCommerce.Storefront/Startup.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/VirtoCommerce.Storefront/Startup.cs b/VirtoCommerce.Storefront/Startup.cs index 2ccbbcd3..36dfbeb4 100644 --- a/VirtoCommerce.Storefront/Startup.cs +++ b/VirtoCommerce.Storefront/Startup.cs @@ -1,8 +1,10 @@ using System; using System.IO; using System.Linq; +using System.Net.Http; using System.Text.Encodings.Web; using System.Text.Unicode; +using System.Threading.Tasks; using FluentValidation.AspNetCore; using GraphQL.Client.Abstractions; using GraphQL.Client.Http; @@ -340,6 +342,8 @@ public void ConfigureServices(IServiceCollection services) services.AddProxy(builder => builder.AddHttpMessageHandler(sp => sp.GetService().CreateAuthHandler())); + services.Configure(options => options.WebSocketKeepAliveInterval = TimeSpan.FromSeconds(50)); + services.AddSingleton(s => { var platformEndpointOptions = s.GetRequiredService>().Value; @@ -427,16 +431,22 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) }); var platformEndpointOptions = app.ApplicationServices.GetRequiredService>().Value; - // Forwards the request only when the host is set to the specified value - app.UseWhen( - context => context.Request.Path.Value.EndsWith("xapi/graphql"), - appInner => appInner.RunProxy(context => + + var httpsPlatformGraphqlEndpoint = new Uri(platformEndpointOptions.Url, "graphql"); + var wssPlatformGraphqlEndpoint = new UriBuilder(httpsPlatformGraphqlEndpoint) + { + Scheme = httpsPlatformGraphqlEndpoint.Scheme == Uri.UriSchemeHttps ? Uri.UriSchemeWss : Uri.UriSchemeWs + }.Uri; + + app.UseWebSockets(); + app.Map("/xapi/graphql", + appInner => { - context.Request.Path = PathString.Empty; - return context.ForwardTo(new Uri(platformEndpointOptions.Url, "graphql")) + appInner.UseWebSocketProxy(_ => wssPlatformGraphqlEndpoint, options => options.AddXForwardedHeaders()); + appInner.RunProxy(context => context.ForwardTo(httpsPlatformGraphqlEndpoint) .AddXForwardedHeaders() - .Send(); - })); + .Send()); + }); app.UseWhen( context => context.Request.Path.Value.EndsWith("/token"),