[CSHARP-2236] Getting Time out, Connection refused by the server (Strange behavior) Created: 06/Apr/18  Updated: 05/Apr/19  Resolved: 31/Aug/18

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

Type: Task Priority: Major - P3
Reporter: Jose Solano [X] Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: connection, connection-string, helper, question, server, timeout
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Test



 Description   

Hi guys,

I was working with Mongo DB 3.4.2, and I am facing an strange issue when accessing data from my API. The error message says:

"ClassName": "System.TimeoutException",
        "Message": "A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : \"1\", ConnectionMode : \"Automatic\", Type : \"Standalone\", State : \"Disconnected\", Servers : [{ ServerId: \"{ ClusterId : 1, EndPoint : \"ServerIp:27017\" }\", EndPoint: \"ServerIp:27017\", State: \"Disconnected\", Type: \"Unknown\", HeartbeatException: \"MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
 ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

And we have already verified the following:

  • There is no block port on the server.
  • The firewall is not blocking the port.

The issue is solved by restarting the Mongo Db Service on the server, however the same issue comes up every 1 hour after restarting the service.

Could you please help me with this,

Thanks,

Jose



 Comments   
Comment by Jose Solano [X] [ 06/Apr/18 ]

Hi Robert,

I was thinking that may be the installation process was corrupted, because only restarting the Mongo process on my server the connection is established, and I don't get the error for at least 1 hour. Also the mongo logs are empty.

Also I noticed this in the exception message:

 "ExceptionMethod": "8\nExecute\nMongoDB.Driver, Version=2.5.0.0, Culture=neutral, PublicKeyToken=null\nMongoDB.Driver.Linq.MongoQueryProviderImpl`1\nSystem.Object Execute(System.Linq.Expressions.Expression)",
        "HResult": -2146233083,
        "Source": "MongoDB.Driver",

I will reinstall the service and see if this issue continue happening, I will let you know.

Thanks for your help,

Jose

Comment by Robert Stam [ 06/Apr/18 ]

I'm not sure what could be wrong.

The exception is being thrown by the .NET Framework itself, not by the C# driver.

The Framework is saying the target machine is refusing the connection.

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