net(客户端)调用IIS(服务端)出现503后,就报操作超时错误
服务端环境:
IIS
客户端环境:
windowsxp + iis + .net
调用时出现如下错误:
System.Net.WebException: 远程服务器返回错误: (503) 服务器不可用。
在 System.Net.HttpWebRequest.GetResponse()
在 TestWebRequest.WebMessage.SendRequest(Byte[] data, String urlStr)
接着就出现如下错误:
System.Net.WebException: 操作超时
在 System.Net.HttpWebRequest.GetRequestStream()
最后一直是这个错误
System.Net.WebException: 操作超时
在 System.Net.HttpWebRequest.GetRequestStream()
当服务器恢复正常时,访问已经是200时,这个线程还是返回操作超时,经过N多测试,最后如下一行完美解决:
myRequest.ServicePoint.Expect100Continue = {
{
Stream streamSend = HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(urlStr);
myRequest.Method = myRequest.ContentType = myRequest.Accept = myRequest.Timeout = ;
myRequest.UserAgent = myRequest.ContentLength = data.Length;
HttpRequestCachePolicy noCachePolicy = myRequest.CachePolicy = noCachePolicy;
{
streamSend = myRequest.GetRequestStream();
streamSend.Write(data, , data.Length);
streamSend.Close();
}
{
log.Debug( streamSend.Close();
streamSend = myRequest = }
{
log.Debug( streamSend.Close();
myRequest = }
];
Stream streamRequest = {
streamRequest = myRequest.GetResponse().GetResponseStream();
}
{
log.Debug( streamRequest.Close();
myRequest = }
Bytes bytes = , );
)
{
bytes.writeByteArr(Bytes.byteSub(byteArr, , count));
count = streamRequest.Read(byteArr, , );
}
streamRequest.Close();
}
{
log.Debug( }
}