diff --git a/src/Momento.Sdk/Internal/ControlGrpcManager.cs b/src/Momento.Sdk/Internal/ControlGrpcManager.cs index 4b59f79a..bbcac40d 100644 --- a/src/Momento.Sdk/Internal/ControlGrpcManager.cs +++ b/src/Momento.Sdk/Internal/ControlGrpcManager.cs @@ -74,14 +74,24 @@ internal sealed class ControlGrpcManager : IDisposable { private readonly GrpcChannel channel; public IControlClient Client { get; } - private readonly string version = "dotnet:" + GetAssembly(typeof(Momento.Sdk.Responses.CacheGetResponse)).GetName().Version.ToString(); + +#if USE_GRPC_WEB + private readonly static string moniker = "dotnet-web"; +#else + private readonly static string moniker = "dotnet"; +#endif + private readonly string version = $"{moniker}:{GetAssembly(typeof(Momento.Sdk.Responses.CacheGetResponse)).GetName().Version.ToString()}"; // Some System.Environment.Version remarks to be aware of // https://learn.microsoft.com/en-us/dotnet/api/system.environment.version?view=netstandard-2.0#remarks - private readonly string runtimeVersion = "dotnet:" + System.Environment.Version; + private readonly string runtimeVersion = $"{moniker}:{System.Environment.Version}"; private readonly ILogger _logger; public ControlGrpcManager(ILoggerFactory loggerFactory, string authToken, string endpoint) { +#if USE_GRPC_WEB + // Note: all web SDK requests are routed to a `web.` subdomain to allow us flexibility on the server + endpoint = $"web.{endpoint}"; +#endif var uri = $"https://{endpoint}"; this.channel = GrpcChannel.ForAddress(uri, new GrpcChannelOptions() { diff --git a/src/Momento.Sdk/Internal/DataGrpcManager.cs b/src/Momento.Sdk/Internal/DataGrpcManager.cs index 4f6a54bd..faab8831 100644 --- a/src/Momento.Sdk/Internal/DataGrpcManager.cs +++ b/src/Momento.Sdk/Internal/DataGrpcManager.cs @@ -226,15 +226,24 @@ public class DataGrpcManager : IDisposable public readonly IDataClient Client; - private readonly string version = "dotnet:" + GetAssembly(typeof(Responses.CacheGetResponse)).GetName().Version.ToString(); +#if USE_GRPC_WEB + private readonly static string moniker = "dotnet-web"; +#else + private readonly static string moniker = "dotnet"; +#endif + private readonly string version = $"{moniker}:{GetAssembly(typeof(Responses.CacheGetResponse)).GetName().Version.ToString()}"; // Some System.Environment.Version remarks to be aware of // https://learn.microsoft.com/en-us/dotnet/api/system.environment.version?view=netstandard-2.0#remarks - private readonly string runtimeVersion = "dotnet:" + Environment.Version; + private readonly string runtimeVersion = $"{moniker}:{Environment.Version}"; private readonly ILogger _logger; - internal DataGrpcManager(IConfiguration config, string authToken, string host) + internal DataGrpcManager(IConfiguration config, string authToken, string endpoint) { - var url = $"https://{host}"; +#if USE_GRPC_WEB + // Note: all web SDK requests are routed to a `web.` subdomain to allow us flexibility on the server + endpoint = $"web.{endpoint}"; +#endif + var uri = $"https://{endpoint}"; var channelOptions = config.TransportStrategy.GrpcConfig.GrpcChannelOptions; if (channelOptions.LoggerFactory == null) { @@ -245,7 +254,7 @@ internal DataGrpcManager(IConfiguration config, string authToken, string host) channelOptions.HttpHandler = new GrpcWebHandler(new HttpClientHandler()); #endif - this.channel = GrpcChannel.ForAddress(url, channelOptions); + this.channel = GrpcChannel.ForAddress(uri, channelOptions); List
headers = new List
{ new Header(name: Header.AuthorizationKey, value: authToken), new Header(name: Header.AgentKey, value: version), new Header(name: Header.RuntimeVersionKey, value: runtimeVersion) }; this._logger = config.LoggerFactory.CreateLogger();