Skip to main content

MongoDB Log Fix: Connection Timeout (SocketException 10060)

Symptom

The hub service log for Netwrix Change Tracker shows the following error:

MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.

System.IO.IOException: Unable to read data from the transport connection:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

System.Net.Sockets.SocketException (10060):
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Cause

Under load, concurrent requests to the MongoDB instance can exceed the driver's connection pool size (maxPoolSize), causing new requests to queue for an available connection. If a request waits longer than the driver's connection timeout (connectTimeoutMS) for a connection to become available, it fails with this error.

Resolution

Increase the IIS pool size and the MongoDB connection timeout to prevent requests from timing out:

  1. Open an elevated Command Prompt and stop IIS:

    iisreset /stop
  2. Navigate to C:\inetpub\wwwroot\Change Tracker Generation 7 (NetCore) Hub\Configs\ and open appsettings.Production.json.

    IMPORTANT: Back up the file before editing it.

  3. Locate the connectionString line:

    "connectionString": "mongodb://%IP_address%"

    Edit the line to add maxPoolSize and connectTimeoutMS:

    "connectionString": "mongodb://%IP_address%/?maxPoolSize=500&connectTimeoutMS=120000"
  4. Save the changes and start IIS:

    iisreset /start

After IIS restarts, the Hub can maintain more concurrent MongoDB connections and allows more time for each request to complete before timing out.