System.TimeoutException: A timeout occurred after 30000ms selecting a server

Exception raised : System.TimeoutException: A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : “1”, ConnectionMode : “ReplicaSet”, Type : “ReplicaSet”, State : “Connected”, Servers : [{ ServerId: “{ ClusterId : 1, EndPoint : “[10.0.1.212]:27017” }”, EndPoint: “10.0.1.212:27017”, ReasonChanged: “Heartbeat”, State: “Disconnected”, ServerVersion: , TopologyVersion: , Type: “Unknown”, HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. —> System.Net.Sockets.SocketException: 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

Hi @Marco_Aerlic - Welcome to the community.

I am not sure if you’ve managed to resolve this yet but in saying so, the timeout exception error you’ve provided generally indicates that the driver in use is unable to connect to the MongoDB instance.

Would you be able to share the following details if you’re still having issues connecting:

  1. Whether you’re able to successfully ping one of the hosts (preferably the PRIMARY):
/// example
ping server1.mongodb.net
  1. Whether you’re able to successfully telnet to one of the hosts on port 27017 (default but also I have noted based off the error you’ve provided):
/// example
telnet server1.mongodb.net 27017
  1. Driver and driver version in use
  2. If you’re running the application from within a container
  3. A code snippet of the connection portion of your code redacting any credentials and sensitive information

I would also recommend you trying to run the following tool to try to help checking Atlas connections from the host server environment: GitHub - pkdone/mongo-connection-check: Tool to check the connectivity to a remote MongoDB deployment, providing advice if connectivity is not achieved.

Regards,
Jason