Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Montago opened this issue Oct 4, 2023 · 4 comments
Open
Assignees

Comments

@Montago
Copy link

Montago commented Oct 4, 2023

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
Copy link
Author

Montago commented Oct 4, 2023

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<System.Int32>.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
Copy link
Author

Montago commented Oct 4, 2023

@FireAndForget1980
Copy link

FireAndForget1980 commented Mar 18, 2024

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants