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

Jason, I know this is late but I stumbled on your response when looking for an answer to a similar problem I am having. Before I get into it any further, I’d like to know more about the tool that you mentioned in your response. I am trying to connect from Windows Server 2022 and the tool lists only uses for Linux, Windows 10 and MacOSX… will it run on the 2022 Server?

Hi Mark - Welcome to the community :wave:

Unfortunately i’m not sure if this works on Windows Server 2022. However, in saying so, the tool is based on the following blog : Paul Done's Technical Blog: Some Tips for Diagnosing Client Connection Issues for MongoDB Atlas. The blog contains details on a few diagnostic tools (some mentioned in my previous reply). If you encounter any errors with those specifically you could go from there supplying any response / errors here on the forums.

Regards,
Jason

Thanks Jason, I’ll give it a look-see. It looks like it has some good information and I’m hoping that it will help. I appreciate your response.

1 Like