none
"Insufficient winsock resources available" exception in .net applications RRS feed

  • Question

  • We have in production a fleet of unattended terminals with 3 main applications running: the main client application, a secondary client application (a WCF duplex net.tcp client) and a 3rd party monitoring application. The secondary client application and monitoring application are connected to a different (more volatile) network segment than the main client application. We found out that in time some of the terminals lose their established TCP connections and when trying to reconnect they get a strange   "Insufficient winsock resources available" exception. Once this happens no more TCP connections can be established from the terminals and this situation is resolved only by restarting the machines. The issue affects only the WCF secondary application and the monitoring application. The main client application usually remains connected.

    Exceptions and errors:

    We get the following WCF connect exceptions when we try to connect: 

    System.InsufficientMemoryException: Insufficient winsock resources available to complete socket connection initiation. ---> 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 10.241.158.38:8732

       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)

       at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)

       at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)

     

    .Net Socket connect exception (connecting to a local port):

    System.Net.Sockets.SocketException (0x80004005): An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full 127.0.0.1:10011

     

    Event log exception:

    System log - Warning -TCP/IP failed to establish an outgoing connection because the selected local endpoint was recently used to connect to the same remote endpoint. This error typically occurs when outgoing connections are opened and closed at a high rate, causing all available local ports to be used and forcing TCP/IP to reuse a local port for an outgoing connection. To minimize the risk of data corruption, the TCP/IP standard requires a minimum time period to elapse between successive connections from a given local endpoint to a given remote endpoint.

    Provider: Tcpip

    EventID: 4227

      

    Other factors:

    • There are terminals with a different software image (OS and patches) where our application runs fine and this issue does not occur
    • All the terminals have the Windows security patches (September 2017 level)
    • Disconnected terminals show sufficient RAM memory
    • Disconnected terminals have sufficient dynamic TCP/IP ports configured
    • Disconnected terminals does not show CLOSE_WAIT or TIME_WAIT TCP Connections (while running netstat command)
    Thursday, April 12, 2018 1:34 PM

All replies

  • Hi Bogdan,

    To check whether it is related with WCF or the monitoring app, I suggest you only run the WCF and check whether this issue still happen.

    For this error message, it seems to be related with OS, I suggest you try to install the available updates for your OS.

    In addition, is the net.tcp binding required? I suggest you check whether wshttpbinding will work for you.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, April 13, 2018 6:38 AM
  • Hello,

    The monitoring app is not the issue. It's installed only on 10% of the fleet while the problem occurs on all the terminals (with or without the monitoring app).

    I agree that it is something wrong at the OS level, because I do not see the pending connections (TIME_WAIT or CLOSE_WAIT) that could exhaust the available dynamic ports. Since we are talking about a couple hundred terminals it would be great if we could pinpoint the exact OS patch that could solve the problem.

    Thank you,

    Bogdan.

    Friday, April 13, 2018 6:45 AM
  • I would suggest you try to install the latest updates for a try.

    In addition, I found similiar issue below, I suggest you check whether it will work for you.

    https://stackoverflow.com/questions/24179552/insufficient-winsock-resources?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 16, 2018 1:55 AM