Open Closed

System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'http://localhost:44395/.well-known/openid-configuration'. #7178


User avatar
0
dev@veek.vn created

Hi, I have build the docker-compose to run the project but after logging to the app, the angular site is request to api server by api: http://localhost:44399/api/abp/application-configuration?includeLocalizationResources=false and got the issue below (server status is 500):

System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'http://localhost:44395/.well-known/openid-configuration'. ---> System.IO.IOException: IDX20804: Unable to retrieve document from: 'http://localhost:44395/.well-known/openid-configuration'. ---> System.Net.Http.HttpRequestException: Cannot assign requested address (localhost:44395) ---> System.Net.Sockets.SocketException (99): Cannot assign requested address 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.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|281_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem) at System.Threading.Tasks.TaskCompletionSourceWithCancellation1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.HttpConnectionWaiter1.WaitForConnectionAsync(Boolean async, CancellationToken requestCancellationToken) 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.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.SendAsyncAndRetryOnNetworkError(HttpClient httpClient, Uri uri) at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel) --- End of inner exception stack trace --- at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel) at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel) at Microsoft.IdentityModel.Protocols.ConfigurationManager1.GetConfigurationAsync(CancellationToken cancel) --- End of inner exception stack trace --- at Microsoft.IdentityModel.Protocols.ConfigurationManager1.GetConfigurationAsync(CancellationToken cancel) at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<

My docker compose:

version: '3.7'

services: backoffice-angular: image: aa.core/backoffice-angular:latest container_name: backoffice-angular build: context: ../angular/ dockerfile: Dockerfile ports: - "4200:80" depends_on: - backoffice-api networks: - abp-network

backoffice-api: image: aa.core/backoffice-api:latest container_name: backoffice-api hostname: backoffice-api build: context: . dockerfile: ./src/AA.Core.BackOffice.HttpApi.Host/Dockerfile ports: - "44399:80" restart: on-failure volumes: - type: bind source: ${USERPROFILE}/.abp/cli/ target: /root/.abp/cli/ networks: - abp-network

backoffice-authserver: image: aa.core/backoffice-authserver:latest container_name: backoffice-authserver build: context: ../aspnet-core/ dockerfile: src/AA.Core.BackOffice.AuthServer/Dockerfile ports: - "44395:80" depends_on: mongodb: condition: service_healthy redis: condition: service_healthy volumes: - type: bind source: ${USERPROFILE}/.abp/cli/ target: /root/.abp/cli/ restart: on-failure networks: - abp-network

db-migrator: image: aa.core/backoffice-db-migrator:latest container_name: db-migrator build: context: ../aspnet-core/ dockerfile: src/AA.Core.BackOffice.DbMigrator/Dockerfile depends_on: mongodb: condition: service_healthy volumes: - type: bind source: ${USERPROFILE}/.abp/cli/ target: /root/.abp/cli/ networks: - abp-network

mongodb: container_name: mongodb image: mongo:4.2 ports: - "27017:27017" volumes: - mongodb_data:/data/db networks: - abp-network healthcheck: test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet interval: 10s timeout: 10s retries: 10

redis: container_name: redis image: redis:alpine ports: - "6379:6379" networks: - abp-network healthcheck: test: [ "CMD", "redis-cli","ping" ]

volumes: mongodb_data: name: backoffice_mongodb_data networks: abp-network: name: backoffice-network driver: bridge

ABP Framework version: v7.3.2 UI Type: Angular Database System: MongoDB Tiered (for MVC) or Auth Server Separated (for Angular): Yes Exception message and full stack trace: [Provide any relevant details] Steps to reproduce the issue:


20 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Cannot assign requested address (localhost:44395)

    Is http://localhost:44395/ can communicate in your backoffice-api container?

    Please set the correct AuthServer:Authority URL in your docker environment.

    Example:

    {
      "AuthServer": {
        "Authority": "http://backoffice-authserver",
        "RequireHttpsMetadata": false,
        "MetaAddress": "http://backoffice-authserver",
        "SwaggerClientId": "MyProjectName_Client_Id"
      }
    }
    
    
  • User Avatar
    0
    dev@veek.vn created

    I opened that link on another tab and it's working well but not sure why the request is not working when calling from the Angular app.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    The link can be reached on your computer. But the container is in Docker.

    There are different networks between Docker and your computer.

  • User Avatar
    0
    dev@veek.vn created

    what should I do now?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Please set the correct AuthServer:Authority URL in your docker environment.

    Example:

    {
      "AuthServer": {
        "Authority": "http://backoffice-authserver",
        "RequireHttpsMetadata": false,
        "MetaAddress": "http://backoffice-authserver",
        "SwaggerClientId": "MyProjectName_Client_Id"
      }
    }
    
  • User Avatar
    0
    dev@veek.vn created

    can I send you my project?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Have you tried that?

    https://support.abp.io/QA/Questions/7178/SystemInvalidOperationException-IDX20803-Unable-to-obtain-configuration-from-%27httplocalhost44395well-knownopenid-configuration%27#answer-3a1281eb-547b-98e3-ba12-1a21983d3197

    Also, there is an etc/docker folder in the template project that you can refer to.

    If your project doesn't have,You can try to create a new template project to see it.

  • User Avatar
    0
    dev@veek.vn created

    that is my question link :)))

    I have tried but still not working, let me try again with empty project, if still not work, I will send that to you

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I have tried but still not working

    What is your AuthServer:Authority value? What are the logs after setting the AuthServer:Authority ?

  • User Avatar
    0
    dev@veek.vn created

    my setup on api.host: "AuthServer": { "Authority": "http://localhost:44395", "RequireHttpsMetadata": "false", "SwaggerClientId": "BackOffice_Swagger", "PasswordlessClientId": "BackOffice_App", "PasswordlessScope": "openid offline_access BackOffice" },

    on authserver: "AuthServer": { "Authority": "http://localhost:44395", "RequireHttpsMetadata": "false" },

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    What are the logs after setting the AuthServer:Authority to http://backoffice-authserver ?

  • User Avatar
    0
    dev@veek.vn created

    System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'http://localhost:44395/.well-known/openid-configuration'. ---> System.IO.IOException: IDX20804: Unable to retrieve document from: 'http://localhost:44395/.well-known/openid-configuration'. ---> System.Net.Http.HttpRequestException: Cannot assign requested address (localhost:44395) ---> System.Net.Sockets.SocketException (99): Cannot assign requested address 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.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|281_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you try to use http://backoffice-authserver to replace the http://localhost:44395?

    Because your container can't reach the http://localhost:44395 in docker.

  • User Avatar
    0
    dev@veek.vn created

    replace on authserver and api appsetting, right? how about angular env?

  • User Avatar
    0
    dev@veek.vn created

    This issue occurs after I log in successfully. It still works when I access the Angular page without logging in.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Thanks. I will ask our colleagues.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    bwt we have a document about the deployment to docker https://docs.abp.io/en/commercial/latest/startup-templates/application/deployment-docker-compose?UI=MVC&DB=EF&Tiered=Yes

  • User Avatar
    0
    dev@veek.vn created

    I just want to run Docker Compose with the debug mode instead of running the API and auth server projects

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I have asked our colleagues about docker knowedge, We will reply to you soon.

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Hello,

    You are using angular with separate auth-server template, it seems you have mis-configurations on docker-compose file.

    We've detailed explanation about the environment variables when running on docker: https://docs.abp.io/en/commercial/latest/startup-templates/application/deployment-docker-compose?UI=NG&DB=EF&Tiered=Yes#bookstore-api

    Please examine the samples and the generated docker-compose files when you've created a new template (or just create a new template to compare).

    As far as I see, you receive the error when you make a request from front-end to back-end; the back-end tries to validate the token but can't reach to auth-server. Specifically, you are missing environment configuration for your docker back-end service based on the docker-compose file you've shared in your initial question.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11