`new HttpRequestMessage(…)` in docker application cannot access internet?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



`new HttpRequestMessage(…)` in docker application cannot access internet?



The following code (.Net core 2.1, created using visual studio) runs without error if not in docker.


var uri = new Uri("https://usbtrustgateway.usbank.com/portal/login.do");
using(var request = new HttpRequestMessage(RequestUri: uri, Method: httpMethod)) {



However, it got the following error when running in docker(Linux) or debugging running "docker-compose" using Visual Studio?



System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.CurlException: Couldn't connect to server
at System.Net.Http.CurlHandler.ThrowIfCURLEError(CURLcode error)
at System.Net.Http.CurlHandler.MultiAgent.FinishRequest(StrongToWeakReference``1 easyWrapper, CURLcode messageResult)
--- End of inner exception stack trace ---
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)





Try restarting docker. I find that Docker on Windows, and any containers within, can't access the Internet when I first start it, so every day I have to restart it. It might not be relevant to your situation, of course :)
– John
Aug 13 at 4:47



docker





what is your docker setup? What ports are you exposing?
– kfrajer
Aug 13 at 4:47





@kfrajer I don't think the ports exposed matter :)
– John
Aug 13 at 4:48




1 Answer
1



Following the github issue below, it seems that you have an underlying request error from as far the the exception tells. Not much info, you've got to check it out from the request side.



https://github.com/dotnet/corefx/issues/24472



Also, from a personal point of view, docker usually has issues with connectivity on my side so try playing the turn it off and on game and see if it works, else you'll have to debug things on the curl side. Might be the same as the github issue as stated.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS