从 Windows 服务下载文件时 System.Net.Sockets.SocketException (0x80004005) 代码

问题描述

下载文件时,我得到:

System.Net.sockets.socketException (0x80004005)。

我有一个 C# 服务应用程序。在尝试下载文件时,我的一位客户出现以下异常。

代码

        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);
        }

例外

下载文件中的错误 Œfi∑®¡¨Ω”µΩ'∂≥Ã∑˛ŒÒ∆~ System.Net.sockets.socketException (0x80004005): “…”⁄ƒø±Íº∆À„ª˙ª˝º´æ‹æ¯£¨Œfi∑®¡Ω”°£ 108.160.165.189:443 在 System.Net.sockets.socket.DoConnect(EndPoint endPointSnapshot,SocketAddress socketAddress) 在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,Socket s4,Socket s6,Socket& socket,IPAddress& address,ConnectSocketState state,IAsyncResult asyncResult,Exception&异常)

用户可以从浏览器下载文件。但是从服务应用程序中会出现问题。该服务以系统用户身份运行。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...