Altinn / app-localtest

Solution for testing apps locally on your own machine
8 stars 14 forks source link

Not able to open test application when running app-localtest with podman #84

Open sbang opened 7 months ago

sbang commented 7 months ago

Description of the bug

I did the following:

  1. Created a test application as outlined in https://docs.altinn.studio/nb/app/app-dev-course/

  2. Cloned app-localtest and followed the podman instructions in README.md

  3. I tried opening http://local.altinn.cloud:8000/ but got an error message

     An exception occured while fetching applicationData
     No application running on http://host.docker.internal:5005
     Please start your an app on this adress. Typically run the following command in an app directory.
    
     dotnet run
    
  4. However the application has been started with "dotnet run" as outlined in README.md and is running, listening to port 5005

    image
  5. Tried opening http://host.docker.internal:5005 with curl but got "could not resolve host host.docker.internal":

      EMEAAD+sbang@AAP-5CG32757DH:~$ curl --verbose http://host.docker.internal:5005
        % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                       Dload  Upload   Total   Spent    Left  Speed
        0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Could not resolve host: host.docker.internal
      * Closing connection
      curl: (6) Could not resolve host: host.docker.internal
      EMEAAD+sbang@AAP-5CG32757DH:~$
  6. I tried adding host.docker.internal as an alias for localhost in c:\Windows\System32\Drivers\etc\hosts

      # localhost name resolution is handled within DNS itself.
              127.0.0.1       localhost, host.docker.internal
              ::1             localhost, host.docker.internal
  7. This made http://host.docker.internal:5005 work with curl (but got 404 on the root)

  8. But http://local.altinn.cloud:8000/ still got the same error message

  9. Deleted the containers in podman and ran "podman compose --file podman-compose.yml up -d --build" again

  10. After the containers were up, tried http://local.altinn.cloud:8000/ but still got the same error message

Steps To Reproduce

  1. Create an Altinn test application
  2. Clone test application to a windows 11 machine
  3. Install podman desktop as outlined in the app-localtest README
  4. Run app-localtest with podman as outlined in the app-localtest README
  5. Try opening http://local.altinn.cloud:8000/ in a web browser and get the error message

Additional Information

Windows 11 Enterprise, Microsoft .Net SDK 6.0.418, podman desktop 1.7.1, podman 4.9.2

olebhansen commented 2 months ago

Hi, if this is still an issue: Can you try replacing host.docker.internal in\podman-compose.yml and \src\appsettings.Podman.json with the output from running hostname in windows + a ".local" postfix? E.g.

{
  "AuthnGeneralSettings": {
    "PlatformEndpoint": "http://localhost:5101/"
  },
  "LocalPlatformSettings": {
    "LocalAppMode": "http",
    "LocalFrontendHostname": "MyLocalHostName.local",
    "LocalAppUrl": "http://MyLocalHostName.local:5005",
    "LocalTestingStorageBasePath": "/AltinnPlatformLocal/",
    "LocalTestingStaticTestDataPath": "/testdata/",
    "LocalGrafanaUrl": "http://monitoring_grafana:3000"
  }
}

I was facing the same problem and think this was the change that resolved the same error as you observed.

olebhansen commented 1 month ago

FYI; Also found that (in my case) the networking must be set to "user-mode" when creating the podman machine. Full description is in the linked PR.