I am facing application performance issue because of "An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full" error.
Basically application flow is 1.Application hits to web API and WebAPI hits to the database.
To resolve this issue,
- I have increased maxport upto 15000 - https://learn.microsoft.com/en-us/troubleshoot/windows-client/networking/connect-tcp-greater-than-5000-error-wsaenobufs-10055
- Verified all the connection closed at the application level. 3.I am using "Using" keyword in my application. 4.I have verified,there are so many connections are available with Time_wait state.
Please let me know if you have any other solution apart from this.
Code
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);
}
}
Thanks