使用 .NET 1.1 的此 Web 服务的生产版本不存在此问题。这是在 Windows Server 2003 上运行 .NET 4.0 的测试环境中进行的。
我收到以下异常时遇到问题:
System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at HTP.RHIO.PIRManager.TargetWS.PIRService.Upload(Transmission t_request)
at HTP.RHIO.PIRManager.Manager.PIRManager.Upload(Transmission request)
当我的 web 服务的 Upload 方法调用另一个 web 服务的 Upload 方法时会发生这种情况。超时几乎立即发生,大约 1/3 秒(注意 log_datetime 列)
代码:(它在异常输出中记录间隔的行尚未实现,这就是它没有出现在输出中的原因。它应该下降到默认值间隔 = 60 [*1000])
int interval = 0;
try
{
try
{
interval = Convert.ToInt16(System.Configuration.ConfigurationSettings.AppSettings["RealTimeTimeOutSeconds"]);
}
catch(Exception ex)
{
interval = 60;
}
interval = interval * 1000;
target.Timeout = interval;
trans = target.Upload(trans);
}
catch(System.Net.WebException ex)
{
request.TransmissionHeader.MessageCode = GetReturnMessageCode(ex);
request.TransmissionHeader.Message = ex.Message;
Log(request.TransmissionHeader, "Upload", "FAILED", "(Timeout = " + interval.ToString() + ") " + ex.ToString(), 1);
trans = TA1forFailedRealtimeUpload(trans.TransmissionHeader);
request = ConvertToLocal(trans, request);
Log(request.TransmissionHeader, "Upload", "SENDING", "Responding to sender with TA1", 1);
return request;
}
}
并从我的网络服务的 web.config 文件中:
<httpRuntime executionTimeout="600" maxRequestLength="2000000"/>