Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net core docker centos HttpRequest error: (Socket Exception) Resource temporarily unavailable

I have spent a lot of time and tried everything that I could find on Google but could not make it work.

  1. I have a working docker container with a .Net Core app 3.1 Blazer.
  2. I have hosted this on a Linux server centOS 8. It looks like a clear docker container without Kubernetes, etc...
  3. I can open my web site and use it

But I can't send requests from my app, something like the following:

var response = await (await httpClient.GetAsync($"requestString}")).Content.ReadAsStringAsync();  

At this part of code i have error:

Unhandled exception rendering component: Resource temporarily unavailable System.Net.Http.HttpRequestException: Resource temporarily unavailable ---> System.Net.Sockets.SocketException (11): Resource temporarily unavailable at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken) --- End of inner exception stack trace ---

like image 974
Greg Avatar asked Jun 18 '20 21:06

Greg


2 Answers

Turn off firewalld, then restart docker.

sudo systemctl stop firewalld
sudo systemctl disable firewalld
like image 87
Greg Avatar answered Oct 03 '22 18:10

Greg


I had a similar problem with a netcore app which could not access a custom hosts entry.

Kudos to @gekctek for pointing me in the right direction, I found that my docker container could access the internet, but that the container could not access a custom entry in my host's /etc/hosts file

To get around this, I added a volume mapping in the docker-compose file so that the container's /etc/hosts entry would match that of the host, and it worked

enter image description here

like image 32
Andries Koorzen Avatar answered Oct 03 '22 18:10

Andries Koorzen