调用失败:System.Net.WebException: 基础连接已经关闭: 连接被意外关闭。
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
在 System.Net.HttpWebRequest.GetRequestStream()
在 WCS.Common.Util.CSHttpHelp.HttpPost(String postUrl, String postBody)
在 Client.Call(String action, String floor, Int32 type)
public static string HttpPost(string postUrl, string postBody)
{
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(postUrl);
request.ContentType = "application/json";
request.Method = "POST";
request.Timeout = 300000;
request.KeepAlive = false;
request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(postBody);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
using (System.IO.StreamReader myreader = new System.IO.StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
return myreader.ReadToEnd();
}
}
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
你在WebRequest 请求之前加上这2句试试
不懂这个语言
是否可以抓包看看,看下http的交互的时候有什么异常,是否在这种异常下程序出了bug?
还有就是没有成功啥的
先确定你请求的接口返回是不是文本类型
StreamReader 单独try看看异常