Connection time out

this message appears to me, when i want to add an item just like in the youtube tutorial with mongodb

A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode : Primary } }, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/registodeservicosgerais-shard-00-00.q6br3.mongodb.net:27017" }", EndPoint: "Unspecified/registodeservicosgerais-shard-00-00.q6br3.mongodb.net:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.InvalidOperationException: Invalid BinaryConnection state transition from 2 to Failed.
at MongoDB.Driver.Core.Connections.BinaryConnection.ConnectionFailed(Exception exception)
at MongoDB.Driver.Core.Connections.BinaryConnection.<ReceiveBufferAsync>d__51.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.Core.Connections.BinaryConnection.<ReceiveBufferAsync>d__52.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.Core.Connections.BinaryConnection.<ReceiveMessageAsync>d__54.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.Core.Wire

thank you already fixed i had to whitelist the IP from MongoDB

mvp_badge
MVP

What I can deduce from that stack trace is that the connection with the MongoDB database is either absent or unstable ("An exception occurred while opening a connection to the server").

so?

mvp_badge
MVP

thank you already fixed i had to whitelist the IP from MongoDB

mvp_badge
MVP

Good to hear you fixed it! Happy coding :)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.