Home > Back-end >  SignalR between VsCode dev containers using default bridge network
SignalR between VsCode dev containers using default bridge network

Time:11-08

If I create two ASP Core web services in VsCode and implement a SignalR hub in one which is connected to by the other (Dotnet 5, SignalR client library 5.11). This works fine. I can push these services up to Azure and it still works fine.

If however I open these webservices locally in a VsCode dev container and configure them to connect using the default Docker bridge network and the default forwarded port, I get a Connection Refused exception on the HubConnection.StartAsync call.

Why is this and how do I fix it?

I've tried a few things, using the http and https ports, disabling SSL verification in the client service but nothing works so far. I think I need some information on why this isn't working in the first place before I have much chance of coming up with a solution.

CodePudding user response:

The problem was that that Kestrel was still listening on the default network interface inside the Docker container and I needed to reconfigure it to listen on all interfaces for the connection to work.

So in launchsettings.json I needed to change applicationUrl from "https://localhost:5003;http://localhost:5002" to "https://0.0.0.0:5003;http://0.0.0.0:5002" and then everything worked pefectly.

  • Related