Closed samuelpratt closed 3 years ago
Hi @samuelpratt,
thanks for your report.
Please if you have time you can prepare a demo where you reproduce this issue?
It will help me investigate this issue faster.
Thanks a lot.
Hi @Burgyn,
Thanks for your response.
Sorry for the delay in getting back to you. I've put code to reproduce this here: https://github.com/samuelpratt/SwaggerForOcelotBug.
The issue seems to be caused when the http port is mapped coming into the container. See the readme file for more details.
Kind regards,
Sam
Hi @samuelpratt, thanks for your effort and sharing demo. This week I'll try to look at it.
Miňo.
Hi @samuelpratt,
this should be fixed in version 4.4.1
which will be released in a few minutes.
Please check it.
Hi @Burgyn,
Thanks for this. This seems to have fixed the issue. However, when testing I noticed something else:
I updated all my Nuget packages to the latest versions. When I update swashbuckle to >v6 it introduces another issue: -
System.MissingMethodException HResult=0x80131513 Message=Method not found: 'Void Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository..ctor()'. Source=MMLib.SwaggerForOcelot StackTrace: at MMLib.SwaggerForOcelot.Aggregates.AggregateRouteDocumentationGenerator..ctor(IOptions
1 routes, IRoutesDocumentationProvider routesDocumentationProvider, IDefinedAggregatorProvider definedAggregatorProvider,
`
It appears that the maintainers of Swashbuckle have made a breaking change to Swashbuckle.AspNetCore.SwaggerGen. SchemaRepository
The original issue is fixed (thank you again!). Do you want me to open another issue for this?
Hi,
I'm glad I helped. Please create the new issue for the problem with the swagger version. Thanks.
Describe the bug Aggregate swagger URL /swagger/docs/aggregates/aggregates doesn't work externally when running in Docker
Expected behavior
To Reproduce
Create an Ocelot API gateway. Create two apis with routes Create an aggregate route Enable on aggragate route documentaton Run the gateway in docker expsosing a port Navigate to http://localhost:/swagger/docs/aggregates/aggregates
Expected: - Request should return 200 Actual Request returns 500 and the following stack trace is seen in the console: - apigateway_1 | fail: Microsoft.AspNetCore.Server.Kestrel[13] apigateway_1 | Connection id "0HM6KSR4JP6EV", Request id "0HM6KSR4JP6EV:00000003": An unhandled exception was thrown by the application. apigateway_1 | System.Net.Http.HttpRequestException: Cannot assign requested address (localhost:8000) apigateway_1 | ---> System.Net.Sockets.SocketException (99): Cannot assign requested address apigateway_1 | at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) apigateway_1 | at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) apigateway_1 | at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|283_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
apigateway_1 | at System.Net.Http.HttpConnectionPool.DefaultConnectAsync(SocketsHttpConnectionContext context, CancellationToken cancellationToken)
apigateway_1 | at System.Net.Http.ConnectHelper.ConnectAsync(Func
3 callback, DnsEndPoint endPoint, HttpRequestMessage requestMessage, CancellationToken cancellationToken) apigateway_1 | --- End of inner exception stack trace --- apigateway_1 | at System.Net.Http.ConnectHelper.ConnectAsync(Func
3 callback, DnsEndPoint endPoint, HttpRequestMessage requestMessage, CancellationToken cancellationToken) apigateway_1 | at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) apigateway_1 | at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) apigateway_1 | at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) apigateway_1 | at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) apigateway_1 | at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) apigateway_1 | at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) apigateway_1 | at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) apigateway_1 | at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) apigateway_1 | at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken) apigateway_1 | at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) apigateway_1 | at MMLib.SwaggerForOcelot.Repositories.DownstreamSwaggerDocsRepository.GetSwaggerJsonAsync(RouteOptions route, SwaggerEndPointOptions endPoint, String docsVersion) apigateway_1 | at MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.Invoke(HttpContext context, ISwaggerEndPointProvider swaggerEndPointRepository, IDownstreamSwaggerDocsRepository downstreamSwaggerDocs) apigateway_1 | at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) apigateway_1 | at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context) apigateway_1 | at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) apigateway_1 | at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) apigateway_1 | at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) apigateway_1 | at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) apigateway_1 | at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext) apigateway_1 | at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)The same request if run from CURL (curl get http://localhost:5000/swagger/docs/aggregates/aggregates) within the container (via docker attach -i bash) returns 200 and the swagger correctly
If it is a possible attach:
swagger.json
.