Open Svetlin17 opened 2 days ago
Dear Reporter! What's your name? Could you attach the following artifacts of the possible bug please →
ocelot.json
We require to use our Issue Template to report bugs.
Is there any further update on this issue?
I will provide all the necessary details, but at a later time.
I am experiencing the same issue as described in issue https://github.com/ThreeMammals/Ocelot/issues/893, where the action of the api does not correctly receive the cancellation token when aborting a request through Ocelot. By calling the api directly and while it is running, I cancel the request and the CancellationToken parameter takes the correct value.
The primary question is: How do you cancel the request? Could you describe your user scenario? The reproduction steps from issue #893 only demonstrate how to detect the issue in the downstream service's logs. The original author did not detail the actual steps for cancellation.
Despite the fix supposedly implemented in pull requests https://github.com/ThreeMammals/Ocelot/pull/1367 and https://github.com/ThreeMammals/Ocelot/pull/902, which are marked as merged and the bug https://github.com/ThreeMammals/Ocelot/issues/893 is marked as closed, the issue still occurs for me in the latest version of Ocelot which is currently 23.3.6.
PR #1367 addressed the issue in the multiplexer, also known as the Aggregation middleware. Are you utilizing the Aggregation feature? It seems we may have overlooked something, and a thorough root cause analysis is necessary. Moreover, since there have been changes to the core and pipeline over the year, it's crucial to re-examine your scenario with a detailed description.
My name is Svetlin.
The action of the api does not correctly receive the cancellation token when aborting a request through Ocelot.
By calling the api directly and while it is running, I cancel the request. The CancellationToken parameter takes the correct value and the appropriate exception is thrown. My GET request from Postman is with this URL:
On the other hand, if I make the same request through Ocelot and cancel the request, the exception is not thrown. My GET request from Postman is with this URL:
Ocelot Program.cs
public class Program
{
const string AllowAnyOrigin = "_allowAnyOriginPolicy";
const string ConfigurationFolder = "OcelotRoutes";
public static void Main(string[] args)
{
CreateHostBuilder(args);
}
//Configuring the gateway to use IHostBuilder instead. Maybe is better when using out of process
public static void CreateHostBuilder(string[] args)
{
// Gotchas: https://ocelot.readthedocs.io/en/latest/introduction/gotchas.html
IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args)
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
.AddEnvironmentVariables();
})
.ConfigureServices((builder, services) =>
{
builder.Configuration.RegisterOptions();
//TO DO: CORS settings
services.AddCors(options =>
{
//Here it should be the url of the app service
//options.AddPolicy(name: AllowAnyOrigin,
// policy => policy.AllowAnyOrigin()
// .AllowAnyHeader()
// .AllowAnyMethod());
});
services.Configure<IISOptions>(options =>
{
options.ForwardClientCertificate = false;
});
services.AddOcelot(builder.Configuration);
AddSwaggerServices(services, builder.Configuration);
})
.RegisterMonitoringOtel()
.ConfigureWebHostDefaults(host =>
{
host.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddOcelot(ConfigurationFolder, hostingContext.HostingEnvironment);
config.AddOcelotWithSwaggerSupport((o) =>
{
o.Folder = ConfigurationFolder;
});
});
host.Configure(app =>
{
app.UseCors(AllowAnyOrigin);
ConfigureSwagger(app);
app.UseOcelot().Wait();
});
});
hostBuilder.Build().Run();
}
private static void ConfigureSwagger(IApplicationBuilder app)
{
if (SwaggerOptions.Instance.IsSwaggerOn)
{
app.UseSwaggerForOcelotUI(ocelotUIOptions =>
{
ocelotUIOptions.PathToSwaggerGenerator = "/swagger/docs";
ocelotUIOptions.ReConfigureUpstreamSwaggerJson = AlterUpstream.AlterUpstreamSwaggerJson;
}, swaggerUIOptions =>
{
swaggerUIOptions.SwaggerEndpoint("../swagger/docs/v1/contracts", "contracts");
});
}
}
private static void AddSwaggerServices(IServiceCollection services, IConfiguration configuration)
{
if (SwaggerOptions.Instance.IsSwaggerOn)
{
services.AddSwaggerForOcelot(configuration, (o) =>
{
});
services.AddSwaggerGen(options =>
{
});
services.AddEndpointsApiExplorer();
}
}
}
ocelot.json is generated on build
{
"Routes": [
{
"SwaggerKey": null,
"AddClaimsToRequest": {
},
"AddHeadersToRequest": {
},
"AddQueriesToRequest": {
},
"AuthenticationOptions": {
"AllowedScopes": [
],
"AuthenticationProviderKey": null,
"AuthenticationProviderKeys": [
]
},
"ChangeDownstreamPathTemplate": {
},
"DangerousAcceptAnyServerCertificateValidator": false,
"DelegatingHandlers": [
],
"DownstreamHeaderTransform": {
},
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7150
}
],
"DownstreamHttpMethod": null,
"DownstreamHttpVersion": null,
"DownstreamHttpVersionPolicy": null,
"DownstreamPathTemplate": "/api/GenerateEntries",
"DownstreamScheme": "http",
"FileCacheOptions": {
"TtlSeconds": null,
"Region": null,
"Header": null,
"EnableContentHashing": null
},
"HttpHandlerOptions": {
"AllowAutoRedirect": false,
"MaxConnectionsPerServer": 2147483647,
"UseCookieContainer": false,
"UseProxy": true,
"UseTracing": false,
"PooledConnectionLifetimeSeconds": null
},
"Key": null,
"LoadBalancerOptions": {
"Expiry": 2147483647,
"Key": "",
"Type": ""
},
"Metadata": {
},
"Priority": 1,
"QoSOptions": {
"DurationOfBreak": 1,
"ExceptionsAllowedBeforeBreaking": 0,
"TimeoutValue": 0
},
"RateLimitOptions": {
"ClientWhitelist": [
],
"EnableRateLimiting": false,
"Period": null,
"PeriodTimespan": 0.0,
"Limit": 0
},
"RequestIdKey": null,
"RouteClaimsRequirement": {
},
"RouteIsCaseSensitive": false,
"SecurityOptions": {
"IPAllowedList": [
],
"IPBlockedList": [
],
"ExcludeAllowedFromBlocked": false
},
"ServiceName": null,
"ServiceNamespace": null,
"Timeout": 0,
"UpstreamHeaderTransform": {
},
"UpstreamHost": null,
"UpstreamHttpMethod": [
"Post"
],
"UpstreamPathTemplate": "/api/GenerateEntries",
"UpstreamHeaderTemplates": {
}
},
{
"SwaggerKey": "contracts",
"AddClaimsToRequest": {
},
"AddHeadersToRequest": {
},
"AddQueriesToRequest": {
},
"AuthenticationOptions": {
"AllowedScopes": [
],
"AuthenticationProviderKey": null,
"AuthenticationProviderKeys": [
]
},
"ChangeDownstreamPathTemplate": {
},
"DangerousAcceptAnyServerCertificateValidator": false,
"DelegatingHandlers": [
],
"DownstreamHeaderTransform": {
},
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 32772
}
],
"DownstreamHttpMethod": null,
"DownstreamHttpVersion": null,
"DownstreamHttpVersionPolicy": null,
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"FileCacheOptions": {
"TtlSeconds": null,
"Region": null,
"Header": null,
"EnableContentHashing": null
},
"HttpHandlerOptions": {
"AllowAutoRedirect": false,
"MaxConnectionsPerServer": 2147483647,
"UseCookieContainer": false,
"UseProxy": true,
"UseTracing": false,
"PooledConnectionLifetimeSeconds": null
},
"Key": null,
"LoadBalancerOptions": {
"Expiry": 2147483647,
"Key": "",
"Type": ""
},
"Metadata": {
},
"Priority": 1,
"QoSOptions": {
"DurationOfBreak": 1,
"ExceptionsAllowedBeforeBreaking": 0,
"TimeoutValue": 0
},
"RateLimitOptions": {
"ClientWhitelist": [
],
"EnableRateLimiting": false,
"Period": null,
"PeriodTimespan": 0.0,
"Limit": 0
},
"RequestIdKey": null,
"RouteClaimsRequirement": {
},
"RouteIsCaseSensitive": false,
"SecurityOptions": {
"IPAllowedList": [
],
"IPBlockedList": [
],
"ExcludeAllowedFromBlocked": false
},
"ServiceName": null,
"ServiceNamespace": null,
"Timeout": 0,
"UpstreamHeaderTransform": {
},
"UpstreamHost": null,
"UpstreamHttpMethod": [
],
"UpstreamPathTemplate": "/api/Contracts/{everything}",
"UpstreamHeaderTemplates": {
}
},
{
"SwaggerKey": null,
"AddClaimsToRequest": {
},
"AddHeadersToRequest": {
},
"AddQueriesToRequest": {
},
"AuthenticationOptions": {
"AllowedScopes": [
],
"AuthenticationProviderKey": null,
"AuthenticationProviderKeys": [
]
},
"ChangeDownstreamPathTemplate": {
},
"DangerousAcceptAnyServerCertificateValidator": false,
"DelegatingHandlers": [
],
"DownstreamHeaderTransform": {
},
"DownstreamHostAndPorts": [
{
"Host": "date.jsontest.com",
"Port": 80
}
],
"DownstreamHttpMethod": null,
"DownstreamHttpVersion": null,
"DownstreamHttpVersionPolicy": null,
"DownstreamPathTemplate": "/",
"DownstreamScheme": "http",
"FileCacheOptions": {
"TtlSeconds": null,
"Region": null,
"Header": null,
"EnableContentHashing": null
},
"HttpHandlerOptions": {
"AllowAutoRedirect": false,
"MaxConnectionsPerServer": 2147483647,
"UseCookieContainer": false,
"UseProxy": true,
"UseTracing": false,
"PooledConnectionLifetimeSeconds": null
},
"Key": null,
"LoadBalancerOptions": {
"Expiry": 2147483647,
"Key": "",
"Type": ""
},
"Metadata": {
},
"Priority": 1,
"QoSOptions": {
"DurationOfBreak": 1,
"ExceptionsAllowedBeforeBreaking": 0,
"TimeoutValue": 0
},
"RateLimitOptions": {
"ClientWhitelist": [
],
"EnableRateLimiting": false,
"Period": null,
"PeriodTimespan": 0.0,
"Limit": 0
},
"RequestIdKey": null,
"RouteClaimsRequirement": {
},
"RouteIsCaseSensitive": false,
"SecurityOptions": {
"IPAllowedList": [
],
"IPBlockedList": [
],
"ExcludeAllowedFromBlocked": false
},
"ServiceName": null,
"ServiceNamespace": null,
"Timeout": 0,
"UpstreamHeaderTransform": {
},
"UpstreamHost": null,
"UpstreamHttpMethod": [
"GET"
],
"UpstreamPathTemplate": "/api/Test/",
"UpstreamHeaderTemplates": {
}
}
],
"DynamicRoutes": [
],
"Aggregates": [
],
"GlobalConfiguration": {
"RequestIdKey": null,
"ServiceDiscoveryProvider": {
"Scheme": null,
"Host": null,
"Port": 0,
"Type": null,
"Token": null,
"ConfigurationKey": null,
"PollingInterval": 0,
"Namespace": null
},
"RateLimitOptions": {
"ClientIdHeader": "ClientId",
"QuotaExceededMessage": null,
"RateLimitCounterPrefix": "ocelot",
"DisableRateLimitHeaders": false,
"HttpStatusCode": 429
},
"QoSOptions": {
"DurationOfBreak": 1,
"ExceptionsAllowedBeforeBreaking": 0,
"TimeoutValue": 0
},
"BaseUrl": "https://localhost/OcelotApiGateway",
"LoadBalancerOptions": {
"Expiry": 2147483647,
"Key": "",
"Type": ""
},
"DownstreamScheme": null,
"HttpHandlerOptions": {
"AllowAutoRedirect": false,
"MaxConnectionsPerServer": 2147483647,
"UseCookieContainer": false,
"UseProxy": true,
"UseTracing": false,
"PooledConnectionLifetimeSeconds": null
},
"DownstreamHttpVersion": null,
"DownstreamHttpVersionPolicy": null,
"CacheOptions": {
"TtlSeconds": null,
"Region": null,
"Header": null,
"EnableContentHashing": null
},
"MetadataOptions": {
"Metadata": {
},
"Separators": [
","
],
"TrimChars": [
" "
],
"StringSplitOption": "None",
"NumberStyle": "Any",
"CurrentCulture": "en-US"
}
},
"SwaggerEndPoints": [
{
"Key": "contracts",
"VersionPlaceholder": "{version}",
"KeyToPath": "contracts",
"Config": [
{
"Name": "Contract Module API",
"Version": "v1",
"Url": "http://localhost:32772/swagger/v1/swagger.json",
"Service": null
}
],
"HostOverride": null,
"TransformByOcelotConfig": true,
"RemoveUnusedComponentsFromScheme": true,
"TakeServersFromDownstreamService": false
}
]
}
logs in Output console in Debug mode after sending and canceling the request through Ocelot from Postman
onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(11) tid(7ad8) 8007277C No such service is known. The service cannot be found in the specified name space.
onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(12) tid(269c) 8007277C No such service is known. The service cannot be found in the specified name space.
Ocelot.RateLimiting.Middleware.RateLimitingMiddleware: Information: requestId: 0HN82UH2SEAJ1:00000002, previousRequestId: No PreviousRequestId, message: 'EndpointRateLimiting is not enabled for /{everything}'
Ocelot.Authentication.Middleware.AuthenticationMiddleware: Information: requestId: 0HN82UH2SEAJ1:00000002, previousRequestId: No PreviousRequestId, message: 'No authentication needed for path '/api/Contracts/odata/Contracts'.'
Ocelot.Authorization.Middleware.AuthorizationMiddleware: Information: requestId: 0HN82UH2SEAJ1:00000002, previousRequestId: No PreviousRequestId, message: '/{everything} route does not require user to be authorized'
'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\winhttp.dll'.
'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\dhcpcsvc6.dll'.
'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\dhcpcsvc.dll'.
'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\OnDemandConnRouteHelper.dll'.
'OcelotApiGateway.exe' (Win32): Unloaded 'C:\Windows\System32\OnDemandConnRouteHelper.dll'
onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(13) tid(68fc) 8007277C No such service is known. The service cannot be found in the specified name space.
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in System.Private.CoreLib.dll
onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(14) tid(68fc) 8007277C No such service is known. The service cannot be found in the specified name space.
onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(15) tid(68fc) 8007277C No such service is known. The service cannot be found in the specified name space.
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(16) tid(76e4) 8007277C No such service is known. The service cannot be found in the specified name space.
Exception thrown: 'Grpc.Core.RpcException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(17) tid(7ad8) 8007277C No such service is known. The service cannot be found in the specified name space.
Ocelot.Requester.Middleware.HttpRequesterMiddleware: Information: requestId: 0HN82UH2SEAJ1:00000002, previousRequestId: No PreviousRequestId, message: '200 (OK) status code of request URI: http://localhost:32772/odata/Contracts?$orderby=Name asc, FullName asc&$top=99&$skip=0&projectId=4dabc2e0-badf-4c86-b935-4a3d35c944a7&locale=bg-bg&$count=true.'
Exception thrown: 'Microsoft.AspNetCore.Connections.ConnectionResetException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(18) tid(68fc) 8007277C No such service is known. The service cannot be found in the specified name space.
API Code
[HttpGet]
[CustomAuthorization(ServiceMethodSecurityObjectNames.OperationServices_IContractsService_GetContracts)]
public async Task<ActionResult<IQueryable<ContractsListItem>>> GetContracts(ODataQueryOptions<ContractsListItemDTO> options, [FromQuery] Guid projectId, [FromQuery] string locale)
{
var ct = HttpContext.RequestAborted;
try
{
await Task.Delay(5000, ct);
ct.ThrowIfCancellationRequested();
var pagedRequest = CreatePagedRequest(options);
PagedResult<ContractsListItemDTO> contractsPaged = await contractService.GetAllContracts(pagedRequest, projectId, locale);
ApplyOdataFeatures(options, contractsPaged.TotalCount, null);
return Ok(contractsPaged.CurrentPage);
}
catch (OperationCanceledException)
{
return StatusCode(StatusCodes.Status499ClientClosedRequest, "Request was cancelled.");
}
}
My name is Svetlin.
What's your full name? Social networks?
services.Configure<IISOptions>(options => AddSwaggerServices(services, builder.Configuration); // Platform: .net 8 IIS (10.0.22621.1)
It appears you have a hybrid Ocelot application with numerous integrations and customizations. The Ocelot documentation clearly states multiple times that IIS and Swagger are not officially supported:
Please remove all these customizations from your Ocelot application and run a clean basic Ocelot app, only adding the necessary routes, and then demonstrate that the bug remains.
Debugging your customized application is impractical. We require a scenario with a clean Ocelot application and your specific routes; without that, we are unable to assist you.
logs in Output console in Debug mode after sending and canceling the request through Ocelot from Postman
onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(11) tid(7ad8) 8007277C No such service is known. The service cannot be found in the specified name space. onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(12) tid(269c) 8007277C No such service is known. The service cannot be found in the specified name space. Ocelot.RateLimiting.Middleware.RateLimitingMiddleware: Information: requestId: 0HN82UH2SEAJ1:00000002, previousRequestId: No PreviousRequestId, message: 'EndpointRateLimiting is not enabled for /{everything}' Ocelot.Authentication.Middleware.AuthenticationMiddleware: Information: requestId: 0HN82UH2SEAJ1:00000002, previousRequestId: No PreviousRequestId, message: 'No authentication needed for path '/api/Contracts/odata/Contracts'.' Ocelot.Authorization.Middleware.AuthorizationMiddleware: Information: requestId: 0HN82UH2SEAJ1:00000002, previousRequestId: No PreviousRequestId, message: '/{everything} route does not require user to be authorized' 'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\winhttp.dll'. 'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\dhcpcsvc6.dll'. 'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\dhcpcsvc.dll'. 'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\OnDemandConnRouteHelper.dll'. 'OcelotApiGateway.exe' (Win32): Unloaded 'C:\Windows\System32\OnDemandConnRouteHelper.dll' onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(13) tid(68fc) 8007277C No such service is known. The service cannot be found in the specified name space. Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll Exception thrown: 'Grpc.Core.RpcException' in System.Private.CoreLib.dll onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(14) tid(68fc) 8007277C No such service is known. The service cannot be found in the specified name space. onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(15) tid(68fc) 8007277C No such service is known. The service cannot be found in the specified name space. Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(16) tid(76e4) 8007277C No such service is known. The service cannot be found in the specified name space. Exception thrown: 'Grpc.Core.RpcException' in System.Private.CoreLib.dll Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(17) tid(7ad8) 8007277C No such service is known. The service cannot be found in the specified name space. Ocelot.Requester.Middleware.HttpRequesterMiddleware: Information: requestId: 0HN82UH2SEAJ1:00000002, previousRequestId: No PreviousRequestId, message: '200 (OK) status code of request URI: http://localhost:32772/odata/Contracts?$orderby=Name asc, FullName asc&$top=99&$skip=0&projectId=4dabc2e0-badf-4c86-b935-4a3d35c944a7&locale=bg-bg&$count=true.' Exception thrown: 'Microsoft.AspNetCore.Connections.ConnectionResetException' in System.Private.CoreLib.dll Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll Exception thrown: 'Grpc.Core.RpcException' in System.Private.CoreLib.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll onecore\net\netprofiles\service\src\nsp\dll\namespaceserviceprovider.cpp(613)\nlansp_c.dll!00007FFE143CF6CD: (caller: 00007FFE3236ACF6) LogHr(18) tid(68fc) 8007277C No such service is known. The service cannot be found in the specified name space.
This Ocelot log is abnormal! There's a concurrent mix of Ocelot and Win32 messages. It appears that the Ocelot application is heavily customized with integrated libraries.
Ocelot.Authorization.Middleware.AuthorizationMiddleware: Information: requestId: 0HN82UH2SEAJ1:00000002, previousRequestId: No PreviousRequestId, message: '/{everything} route does not require user to be authorized' 'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\winhttp.dll'. 'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\dhcpcsvc6.dll'. 'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\dhcpcsvc.dll'. 'OcelotApiGateway.exe' (Win32): Loaded 'C:\Windows\System32\OnDemandConnRouteHelper.dll'. 'OcelotApiGateway.exe' (Win32): Unloaded 'C:\Windows\System32\OnDemandConnRouteHelper.dll'
OcelotApiGateway.exe
? Indeed, it seems you've encapsulated Ocelot as a console application with an executable file. However, utilizing IIS in this scenario is quite perplexing! 😄
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
It appears you've integrated a library with the gRPC protocol. We do not officially support this protocol. Have you investigated Ocelot's compatibility with the gRPC .NET assembly? Unfortunately, we cannot provide further assistance. For our team, it would be a waste of time. You must use a clean Ocelot application to identify the bug, as previously explained.
Ultimately, it's clear to me now why the request cannot be cancelled 😉
Removing Swagger and OpenTelemetry (RegisterMonitoringOtel) didnt help. In web.config i made this change and after that the action of the api correctly receives the cancellation token when aborting a request through Ocelot.
<aspNetCore processPath="dotnet" arguments="bin\Debug\net8.0\OcelotApiGateway.dll" hostingModel="InProcess">
But we want to deploy Ocelot app to IIS because of technical limitations related to the project. The request can be cancelled only with hostingModel="InProcess" for now, we are trying to find some solution to configure it with hostingModel="OutOfProcess" in IIS since you recommend it for better performance: https://ocelot.readthedocs.io/en/latest/introduction/gotchas.html#iis.
I am experiencing the same issue as described in issue #893, where the action of the api does not correctly receive the cancellation token when aborting a request through Ocelot. By calling the api directly and while it is running, I cancel the request and the CancellationToken parameter takes the correct value.
Despite the fix supposedly implemented in pull requests #1367 and #902, which are marked as merged and the bug #893 is marked as closed, the issue still occurs for me in the latest version of Ocelot which is currently 23.3.6.
Is there any further update on this issue?