locked
An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. RRS feed

  • Question

  • User-111351935 posted

    Hi All,

    I am getting below error frequently. Could you please help me with this? currentlly, I am doing IIS reset to fix this issue.

    Error is 

    "An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full."

    For error details, Please find the below content

    ERROR Exception caught for request: https://p******.com///**** with Message:Query failed with connection to:https://p************ /SearchCenter_v2900SolrNet.Exceptions.SolrConnectionException: Unable to connect to the remote server ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace ---

    From where this problem is coming. This error is related to the .net Application, Network, or SQL server?

    Thanks in Advance

    Monday, October 19, 2020 6:39 AM

All replies

  • User1535942433 posted

    Hi rajeshsomvanshi,

    As far as I think,it could be port exhaustion. When application(s) makes too many outgoing connections in short time frame or does not dispose outgoing connections properly - you run out of ports.

    More details,you could refer to below article:

    http://web.archive.org/web/20160118151510/http://blogs.technet.com/b/askds/archive/2008/10/29/port-exhaustion-and-you-or-why-the-netstat-tool-is-your-friend.aspx

    Best regards,

    Yijing Sun

    Tuesday, October 20, 2020 7:33 AM
  • User-111351935 posted

    Hi Yijing,

    Thank you so much for your response. Can we resolve this issue by increasing underline infrastructure (For example - CPU, Memory, or anything).

    Thanks again

    Rajesh Somvanshi

    Thursday, October 22, 2020 9:05 AM
  • User1535942433 posted

    Hi rajeshsomvanshi,

    Could you tell us how much RAM?Whether you  set up TCP connections from ports that are greater than 5000?

    If OS runs out of memory for TCP buffers,you could release memory.However,I think the problem is port.You could  increase the maximum number of ephemeral ports.

    More details,you could refer to below article:

    https://support.microsoft.com/en-gb/help/196271/when-you-try-to-connect-from-tcp-ports-greater-than-5000-you-receive-t

    Best regards,

    Yijing Sun

    Friday, October 23, 2020 6:05 AM
  • User753101303 posted

    Hi,

    You could also double check first if it couldn't be caused by a programming error. For example HttpClient is intended to be reused than created again an again. Maybe a similar approach applies to the product you are using?

    Friday, October 23, 2020 9:52 AM
  • User-111351935 posted

    Hi PatriceSc,

    Thank you so much for your response. Please find the below my code details. Could you please help us to optimize the 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);
            }
        }

    Friday, November 13, 2020 10:49 AM
  • User-111351935 posted

    Hi Yij,

    Thank you so much for your response.

    RAM is 24GB

    TCP PORT is 20000.

    Please find the below my code details as well.

    Could you please help us to optimize the 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);
            }
        }
    Tuesday, November 17, 2020 6:22 AM
  • User-689956231 posted

    Exception    SocketException    1    An existing connection was forcibly closed by the remote host    

    Exception    LoadTestErrorLimitExceededException    1    More than 1000 errors of type 'HttpError' and sub type '503 - ServiceUnavailable' have occurred; additional errors of this type will not be reported.    

    00:00:15    INVOSYSTEMS10    Processor    % Processor Time    0    The value 83.33339 exceeds the warning threshold value of 75.    

    00:00:30    INVOSYSTEMS10    Processor    % Processor Time    0    The value 77.82475 exceeds the warning threshold value of 75.    


    00:00:15    INVOSYSTEMS10    Processor    % Processor Time    0    The value 79.26115 exceeds the warning threshold value of 75.    

    00:00:15    INVOSYSTEMS10    Processor    % Processor Time    _Total    The value 76.75616 exceeds the warning threshold value of 75.    


    Exception    SocketException    1,000    An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full    
    Exception    LoadTestErrorLimitExceededException    1    More than 1000 errors of type 'Exception' and sub type 'SocketException' have occurred; additional errors of this type will not be reported.    

    Thursday, February 4, 2021 6:42 AM
  • User-689956231 posted

    Exception    SocketException    1    An existing connection was forcibly closed by the remote host    

    Exception    LoadTestErrorLimitExceededException    1    More than 1000 errors of type 'HttpError' and sub type '503 - ServiceUnavailable' have occurred; additional errors of this type will not be reported.    

    00:00:15    INVOSYSTEMS10    Processor    % Processor Time    0    The value 83.33339 exceeds the warning threshold value of 75.    

    00:00:30    INVOSYSTEMS10    Processor    % Processor Time    0    The value 77.82475 exceeds the warning threshold value of 75.    


    00:00:15    INVOSYSTEMS10    Processor    % Processor Time    0    The value 79.26115 exceeds the warning threshold value of 75.    

    00:00:15    INVOSYSTEMS10    Processor    % Processor Time    _Total    The value 76.75616 exceeds the warning threshold value of 75.    


    Exception    SocketException    1,000    An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full    
    Exception    LoadTestErrorLimitExceededException    1    More than 1000 errors of type 'Exception' and sub type 'SocketException' have occurred; additional errors of this type will not be reported.    

    Please help me

    Thursday, February 4, 2021 6:43 AM