Web Services 0x80004005连接尝试失败,因为连接方在一段时间后没有正确响应

zlhcx6iw  于 2022-11-15  发布在  其他
关注(0)|答案(2)|浏览(280)

我在从ASP.NET应用程序访问Web服务时遇到了这个问题。
但当它托管在Windows服务器中时,问题就会出现。
当它托管在桌面上时,它工作得很好。
我正在使用HttpWebRequest对象调用Web服务
即使它在服务器上从HTML/Java脚本应用程序运行正常,问题也只发生在服务器上托管ASP.NET应用程序中我得到以下错误IIS 8.0安装在服务器上

Unable to connect to the remote server
System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 153.2.228.76: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)
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at VSPTestApplication.UPS.CalculateRate_Click(Object sender, EventArgs e)
System.IO.Stream GetRequestStream(System.Net.TransportContext ByRef)
e3bfsja2

e3bfsja21#

从你的错误信息中我注意到你试图点击一个HTTPS URL。当你在IIS的aspnet中运行时,这可能是一个棘手的问题,因为你的代码在一个不同的用户上下文中运行。并且必要的证书可能没有安装在那个上下文中。例如,如果目标服务器有一个由客户端机器不信任的CA签名的证书(asp.net/iis/windows),那么请求将不会成功。
然而,证书错误会很明显,它不会显示为连接失败。
我建议使用system.net日志工具创建日志文件。这应该有助于解决问题。另外,您应该在windows服务器上运行wireshark,查看服务器尝试连接的位置。原因可能很简单,因为windows服务器没有连接到目标服务器。或者中间可能有一个代理服务器破坏了网络路径。
要设置system.net日志记录,可以将以下配置文件放在运行代码的应用程序所在的目录中。

<?xml version="1.0" encoding="UTF-8" ?>

<configuration>
<system.diagnostics>
<trace autoflush="true" />

<sources>
<source name="System.Net">

<listeners>
    <add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
    <add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Cache">
<listeners>
    <add name="System.Net"/>
</listeners>
</source>
</sources>
<sharedListeners>
    <add
        name="System.Net"
        type="System.Diagnostics.TextWriterTraceListener"
        initializeData="System.Net.trace.log"
    />
</sharedListeners>
<switches>
    <add name="System.Net" value="Verbose" />
    <add name="System.Net.Sockets" value="Verbose" />               
    <add name="System.Net.Cache" value="Verbose" />
</switches>

有关日志记录的更多详细信息:
creating a tracelog with system.net

eqoofvh9

eqoofvh92#

我也面临着同样的问题,并得到解决,只是通过故障排除网络。
在windows中-〉设置-〉网络和互联网-〉网络故障排除程序

相关问题