我正面临应用程序性能问题,因为“由于系统缺少足够的缓冲区空间或队列已满而无法执行套接字上的操作”错误。
基本上应用程序流程是 1.Web API 的应用程序命中和数据库的 WebAPI 命中。
为了解决这个问题,
- 我已将 maxport 增加到 15000 - https://docs.microsoft.com/en-us/troubleshoot/windows-client/networking/connect-tcp-greater-than-5000-error-wsaenobufs-10055
- 验证在应用程序级别关闭的所有连接。3.我在我的应用程序中使用“Using”关键字。4.我已经验证,Time_wait 状态下有很多可用的连接。
如果您有任何其他解决方案,请告诉我。
代码
public IHttpActionResult Products([FromBody] ProductRequest productRequest)
{
if (productRequest != null)
{
var request = Mapper.Map<SolrProductRequest>(productRequest);
var response = _searchProxy.GetProducts(request);
return Ok(response);
}
return BadRequest();
}
public string Get(string relativeUrl, IEnumerable<KeyValuePair<string, string>> parameters)
{
var u = new UriBuilder(_serverUrl);
u.Path += relativeUrl;
var request = (HttpWebRequest)WebRequest.Create(u.Uri);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
var qs = string.Join("&", parameters
.Select(kv => string.Format("{0}={1}", HttpUtility.UrlEncode(kv.Key), HttpUtility.UrlEncode(kv.Value)))
.ToArray());
request.ContentLength = Encoding.UTF8.GetByteCount(qs);
request.ProtocolVersion = HttpVersion.Version11;
request.KeepAlive = true;
try
{
using (var postParams = request.GetRequestStream())
using (var sw = new StreamWriter(postParams))
sw.Write(qs);
using (var response = request.GetResponse())
using (var responseStream = response.GetResponseStream())
using (var sr = new StreamReader(responseStream, Encoding.UTF8, true))
{
var solrResult = sr.ReadToEnd();
//if (CustomValues != null && CustomValues.Count > 0)
//{
// PopulateCustomValues(solrResult);
//}
return solrResult;
}
}
catch (WebException e)
{
throw new SolrConnectionException(e);
}
}
谢谢