1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Angular/ASP.net core app throws "TLS connection" error after using Linux Docker Containers

Discussão em 'Angular' iniciado por Othman Birem, Outubro 3, 2024 às 13:52.

  1. Othman Birem

    Othman Birem Guest

    I have just started a full-stack project with Angular (v18) at the front-end and ASP.net Core (.net 6.0) in the back, and I decided to use docker Linux containers (I have windows 11 Pro).

    The problem is that I still have not touched anything yet, everything is like it is out of the box after i have created the project in Visual Studio except the container's HTTPS port number which I edited so my container can always be in the same port by specifying the "httpPort" and the "sslPort":

    "Container (Dockerfile)": {
    "commandName": "Docker",
    "launchBrowser": true,
    "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
    "environmentVariables": {
    "ASPNETCORE_URLS": "https://+:443;http://+:80"
    },
    "publishAllPorts": true,
    "useSSL": true,
    "httpPort": 5000,
    "sslPort": 5001
    }


    Now I get this error when I execute both ends:

    [vite] http proxy error: /weatherforecast
    Error: Client network socket disconnected before secure TLS connection was established
    at TLSSocket.onConnectEnd (node:_tls_wrap:1727:19)
    at TLSSocket.emit (node:events:531:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)


    I have tried a variety of solutions but none of which worked unfortunately.

    NECISSARY NOTE: Everything was working fine initially when I was using windows containers (hyper-v) but when I wanted to use SQL server I had to switch to Linux containers (WSL) since SQL server's official image is available only in Linux containers, and that's when the mentioned problem started occurring.

    This is actually my first time using docker so I apologize in case where I might be missing anything obvious.

    My Docker file:


    FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
    WORKDIR /app
    EXPOSE 80
    EXPOSE 443

    FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
    ARG BUILD_CONFIGURATION=Release
    WORKDIR /src
    COPY ["TaskManagerSol.Server/TaskManagerSol.Server.csproj", "TaskManagerSol.Server/"]

    RUN dotnet restore "./TaskManagerSol.Server/TaskManagerSol.Server.csproj"
    COPY . .
    WORKDIR "/src/TaskManagerSol.Server"
    RUN dotnet build "./TaskManagerSol.Server.csproj" -c $BUILD_CONFIGURATION -o /app/build

    FROM build AS publish
    ARG BUILD_CONFIGURATION=Release
    RUN dotnet publish "./TaskManagerSol.Server.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app/publish .
    ENTRYPOINT ["dotnet", "TaskManagerSol.Server.dll"]


    I tried installing a TLS self-signed certificate in my machine, as well as modifying the compose.yml or the dockerFile it self but none of which did me any favor.

    Continue reading...

Compartilhe esta Página