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

getting error when use service discovery #287

Closed
alihmaidi1 opened this issue Feb 5, 2024 · 7 comments
Closed

getting error when use service discovery #287

alihmaidi1 opened this issue Feb 5, 2024 · 7 comments
Assignees
Labels
waiting-8-days Closing after 8 days of waiting for the additional info requested.

Comments

@alihmaidi1
Copy link

Describe the bug

 Start processing HTTP request GET localhost:5226/swagger/teacher/swagger.json
info: System.Net.Http.HttpClient.Default.ClientHandler[100]
      Sending HTTP request GET localhost:5226/swagger/teacher/swagger.json
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.NotSupportedException: The 'localhost' scheme is not supported.
         at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.<SendCoreAsync>g__Core|5_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken)
         at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.<SendCoreAsync>g__Core|5_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken)
         at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
         at MMLib.SwaggerForOcelot.Repositories.DownstreamSwaggerDocsRepository.GetSwaggerJsonAsync(RouteOptions route, SwaggerEndPointOptions endPoint, String docsVersion)
         at MMLib.SwaggerForOcelot.Middleware.SwaggerForOcelotMiddleware.Invoke(HttpContext context, ISwaggerEndPointProvider swaggerEndPointRepository, IDownstreamSwaggerDocsRepository downstreamSwaggerDocs)
         at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.InvokeCore(HttpContext context, PathString matchedPath, PathString remainingPath)
         at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext)
         at Microsoft.AspNetCore.MiddlewareAnalysis.AnalysisMiddleware.Invoke(HttpContext httpContext)
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
^Cinfo: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...

i try to use service discovery but i get this error


{

  "SwaggerEndPoints": [
    {

      "Key": "Teacher",
      "Config": [{

        "Name": "Teacher Documentation microservice",
        "Version": "v1",
        "UseServiceDiscovery": true,
        "Service": {
          "Scheme": "http",
          "Name": "Teacher",
          "Path": "/swagger/teacher/swagger.json"
        }

      }]
    }
  ]
}

this is my SwaggerEndPoints


{


  "GlobalConfiguration": {
    "BaseUrl": "http://localhost:5297",
    "ServiceDiscoveryProvider": {
      "Scheme": "http",
      "Host": "localhost",
      "Port": 8500,      
      "Type": "Consul",
      "PollingInterval": 1000
      
    }
    
    
  }
}

this is GlobalConfiguration

now after search i find you need to add schema when get swagger by service registry

@Burgyn
Copy link
Owner

Burgyn commented Feb 5, 2024

Hi,

please can you provide a demo example with minimal reproduction steps?

@Burgyn Burgyn added the waiting-8-days Closing after 8 days of waiting for the additional info requested. label Feb 5, 2024
@alihmaidi1
Copy link
Author

yes here is my repo you can check it @Burgyn
https://github.com/alihmaidi1/schoolMicroservice

@alihmaidi1
Copy link
Author

alihmaidi1 commented Feb 5, 2024

{
  "SwaggerEndPoints": [
    {

      "Key": "Teacher",
      "Config": [{

        "Name": "Teacher Documentation microservice",
        "Version": "v1",
        "UseServiceDiscovery": true,
        "Url":"http://localhost:5226/swagger/teacher/swager.json" //this will work 
        

     "Service": {
          "Scheme": "http",
          "Name": "Teacher",
          "Path": "/swagger/teacher/swagger.json"
        }
// This not work with me because this package  make url  "localhost:5226/swagger/teacher/swagger.json"
Without http This make error

@Burgyn

@Burgyn
Copy link
Owner

Burgyn commented Feb 6, 2024

Hi @alihmaidi1,

can you please provide a working project? Ideally without database dependency (note in your example you have published a secret) and with Consul service discovery configured? I don't know Consul, so I don't plan to learn it and figure out how to configure it. Ideally if you provide it as a docker-compose let me know how to download it and run/debug it.

Otherwise, unfortunately I don't have the space to devote to it. Thank you for your understanding.

@alihmaidi1
Copy link
Author

alihmaidi1 commented Feb 7, 2024

Yes, you can view the project. I have prepared for you a docker-compose file and I have also prepared for you two services, the first for admin and it getting swagger by 'url' and it work and the second getting swagger by 'Service' and it don't work

https://github.com/alihmaidi1/schoolMicroservice

@Burgyn

@raga70
Copy link
Contributor

raga70 commented Mar 27, 2024

Hi, @alihmaidi1
Support for Consul Service discovery was added yesterday

@alihmaidi1
Copy link
Author

thank you man :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-8-days Closing after 8 days of waiting for the additional info requested.
Projects
None yet
Development

No branches or pull requests

3 participants