[CSHARP-1862] System.AggregateException: An exception occurred while opening a connection to the server. Created: 05/Dec/16  Updated: 03/Dec/20  Resolved: 03/Dec/20

Status: Closed
Project: C# Driver
Component/s: Connectivity
Affects Version/s: 2.3
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Sagar Thakur Assignee: Unassigned
Resolution: Done Votes: 0
Labels: question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mongodb 3.0.6 running on localhost, Win 7 ultimate 64bit



 Description   

I am running a lot of operations in parallel which are trying to access the database. I get this error on one of the UpdateOneAsync() operations(this is not always the same, I get this exception on other functions as well).

System.AggregateException:

{"An exception occurred while opening a connection to the server."}

StackTrace:

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Data.MongoContext.Update[T](String collectionName, Expression`1 filter, Dictionary`2 fieldsToUpdate) in C:\...Data\MongoContext.cs:line 163
..

The InnerException has more info:

ConnectionId: {{ ServerId :

{ ClusterId : 1, EndPoint : "Unspecified/localhost:27017" }

, LocalValue : 163 }}

InnerException:

{"Timed out connecting to Unspecified/localhost:27017. Timeout was 00:00:30."}

Message: An exception occurred while opening a connection to the server.

Source: MongoDB.Driver.Core

StackTrace: at MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__48.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.Core.Servers.Server.<GetChannelAsync>d__27.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.<ExecuteAsync>d__39.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.OperationExecutor.<ExecuteWriteOperationAsync>d__3`1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.MongoCollectionImpl`1.<ExecuteWriteOperationAsync>d__61`1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.MongoCollectionImpl`1.<BulkWriteAsync>d__22.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.MongoCollectionBase`1.<UpdateOneAsync>d__43.MoveNext()

I have tried changing the connectionpoolsize, waitqueuemultiple, waitqueuesize, maxidletimems and also making the MongoContext as a static variable. All that does not seem to help. I even tried to downgrade to 2.2 and 2.1 versions of the driver and also upgraded it to 2.4 but nothing seems to fix that issue.



 Comments   
Comment by Jeffrey Yemin [ 03/Dec/20 ]

Apologies for not answering on this ticket immediately.

Issues like this are almost always related to connectivity issues outside of the control of the driver, not a driver bug.

For anyone else experiencing issues like this, here are some resources to get questions answered more quickly:

  • Our MongoDB support portal, located at support.mongodb.com
  • Our MongoDB community portal, located here
  • If you are an Atlas customer, there is free support offered 24/7 in the lower right hand corner of the UI

Thank you!

Generated at Wed Feb 07 21:40:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.