Google Groups

Can't connect to mongodb: "System lacked sufficient buffer space or because a queue was full"


Rex Morgan Mar 22, 2012 9:24 AM
Posted in group: mongodb-user
I'm getting the following exception occasionally when attempting to connect to our mongodb in production (we are using the mongo-csharp-drivers v1.3.1.4349):

<Message>Unable to connect to the primary member of the replica set: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full 192.168.3.28:27017.</Message>
<Source>MongoDB.Driver</Source>
<StackTrace>   at MongoDB.Driver.Internal.ReplicaSetConnector.Connect(TimeSpan timeout, ConnectWaitFor waitFor)
   at MongoDB.Driver.MongoServer.Connect(TimeSpan timeout, ConnectWaitFor waitFor)
   at MongoDB.Driver.MongoServer.Connect(TimeSpan timeout)
   at MongoDB.Driver.MongoServer.Connect()
   at Infrastructure.Configuration.MongoDbRegistry.&lt;.ctor&gt;b__0(IContext cx)</StackTrace>
<TargetSite>Void Connect(System.TimeSpan, MongoDB.Driver.ConnectWaitFor)</TargetSite>
<InnerException>
    <Message>An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full 192.168.3.28:27017</Message>
    <Source>System</Source>
    <StackTrace>   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
   at MongoDB.Driver.Internal.MongoConnection.Open()
   at MongoDB.Driver.Internal.MongoConnection.GetNetworkStream()
   at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, SafeMode safeMode)
   at MongoDB.Driver.Internal.MongoConnection.RunCommand(String collectionName, QueryFlags queryFlags, CommandDocument command)
   at MongoDB.Driver.MongoServerInstance.VerifyState(MongoConnection connection)
   at MongoDB.Driver.MongoServerInstance.Connect(Boolean slaveOk)
   at MongoDB.Driver.Internal.ReplicaSetConnector.ConnectWorkItem(Object argsObject)</StackTrace>
    <TargetSite>Void DoConnect(System.Net.EndPoint, System.Net.SocketAddress)</TargetSite>
</InnerException>


The article makes it sound like we are running out of available TCP ports on our server, but I'm unsure if this is correct or not. I'm hoping someone could explain the error a little more, and point me in the right direction.