System.Net.Sockets.SocketException (0x80004005) while downloading a file from windows service

0

While downloading a file, I got:

System.Net.Sockets.SocketException (0x80004005).

I have a C# service application. While trying to download the file, one of my clients got the following exception.

Code

        try
        {
            using (var client = new WebClient())
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
                client.DownloadFile(url, name);
                return true;
            }
        }
        catch (Exception e)
        {
            Logger.Error("Error inside DownloadFile");
            Logger.Error(e.message);
            Logger.Error(e.InnerException);
        }

Exception

Error inside DownloadFile Œfi∑®¡¨Ω”µΩ‘∂≥Ã∑˛ŒÒ∆˜ System.Net.Sockets.SocketException (0x80004005): ”…”⁄ƒø±Íº∆À„ª˙ª˝º´æ‹æ¯£¨Œfi∑®¡¨Ω”°£ 108.160.165.189:443 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

From the browser, a user can download a file. But from a service application the issue occurs. The service is running as the system user.

c#
windows-services
webclient
socketexception
webclient-download
asked on Stack Overflow Jan 18, 2021 by Ijas • edited Apr 10, 2021 by Peter Mortensen

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0