I'am facing issue with establishing SignalR connection on docker (IIS works well).
Main goal is to run docker compose and send data from nodeRed container to webApp (.net core 3.1 Blazor) and via versa. I made docker network and put there both containers succesfully.
Problem is that my SignalR connections fails with "Connection refused". I see it'll be some banality, but can't find out.
page.razor
protected override async Task OnInitializedAsync()
{
hubConnection = new HubConnectionBuilder()
.WithUrl("http://AICsystemApp/nodeRedHub")
.Build();
hubConnection.On<string, string>("ReceiveCommand", (user, message) =>
{
var encodedMsg = $"{destination}: {message}";
nodeRedOutput.Add(encodedMsg);
StateHasChanged();
});
await hubConnection.StartAsync();
}
Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80 /* tried 8024 */
EXPOSE 443 /* tried 44324 */
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["AICsystemApp/AICsystemApp.csproj", "AICsystemApp/"]
RUN dotnet restore "AICsystemApp/AICsystemApp.csproj"
COPY . .
WORKDIR "/src/AICsystemApp"
RUN dotnet build "AICsystemApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "AICsystemApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AICsystemApp.dll"]
docker-compose.override.yml
version: '3.4'
services:
aicsystemapp:
container_name: AICsystemApp
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "8024:80"
- "44324:443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
networks:
- my-network
networks:
my-network:
external: true
I made SignalR connection with official documentation and just used "http://AICsystemApp/nodeRedHub" instead of "NavigationManager.ToAbsoluteUri("/chathub")" acordingly to this thread : how to run StartAsync connection of signalr blazor client in docker image?
I am confused that docker runs containers in https:// but if I use "https://AICsystemApp/nodeRedHub" I get error: "The remote certificate is invalid according to the validation procedure."
Edit* Find out if I use "https://AICsystemApp:44324/nodeRedHub" I have not errror with https, but same "Connection refused" error. Leads nowhere but interesting.
If you need additional information, I am here ready to respond! :) Thanks in advance.
Also tried ipaddress:port/nodeRedHub, same result.