Burgyn / MMLib.SwaggerForOcelot

This repo contains swagger extension for ocelot.
MIT License
349 stars 93 forks source link

Added ApiController to Ocelot Gateway, but gets 404 when requesting it #277

Open Montago opened 10 months ago

Montago commented 10 months ago

This might only be a configuration issue..

I've added an ApiController to my gateway / swagger hub project and enabled GenerateDocsForGatewayItSelf This now shows my Api: image

But when i call it i get a 404

Any ideas why ?

Montago commented 10 months ago

I've been investigating this the whole day and it seems that either Ocelot or MMLib.SwaggerForOcelot is obstructing the default Routing of ASP.NET

I've tried adding custom routes to the Routes config that should point directly to the static files, MvcController or ApiController ... and all of them result in a 90seconds timout and 404 or 503 ..

Category: Ocelot.Responder.Middleware.ResponderMiddleware EventId: 0 SpanId: 431e659392ee5182 TraceId: f0231cef34db475c66705a8630a9aac4 ParentId: 1b07f00d48eeee34 RequestId: 4000000e-000a-f900-b63f-84710c7967bb RequestPath: /Home/Index

requestId: 4000000e-000a-f900-b63f-84710c7967bb, previousRequestId: no previous request id, message: Error Code: RequestTimedOutError Message: Timeout making http request, exception: System.Threading.Tasks.TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 90 seconds elapsing. ---> System.TimeoutException: The operation was canceled. ---> System.Threading.Tasks.TaskCanceledException: The operation was canceled. ---> System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request.. ---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request. --- End of inner exception stack trace --- at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder1.StateMachineBox1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](Memory1 buffer, CancellationToken cancellationToken) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async) at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) --- End of inner exception stack trace --- --- End of inner exception stack trace --- at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean telemetryStarted, HttpResponseMessage response, CancellationTokenSource cts, CancellationToken cancellationToken, CancellationTokenSource pendingRequestsCts) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Ocelot.Requester.HttpClientHttpRequester.GetResponse(HttpContext httpContext) errors found in ResponderMiddleware. Setting error response for request path:/Home/Index, request method: GET

Montago commented 10 months ago

Suggestions tried - didnt work https://stackoverflow.com/questions/56956831/can-ocelot-have-its-own-controller-actions

and this https://github.com/ThreeMammals/Ocelot/issues/730

FireAndForget1980 commented 5 months ago

I've had the same problem with .net8, and Ocelot from 17.0.0 to 23.1.0.

I don't know the reason, but I think it has to do with .net8 and the shortcut to map controllers, in the following image you can see how I got it to work.

image

Best, FireAndForget1980

navidkhalilian commented 3 months ago

If you do not add a QoS section, QoS will not be used, however Ocelot will default to a 90 seconds timeout on all downstream requests.

https://ocelot.readthedocs.io/en/latest/features/qualityofservice.html