[CSHARP-2682] A timeout occured after 30000ms; not able to make a connection to MongoDB Created: 09/Aug/19  Updated: 26/Aug/19  Resolved: 26/Aug/19

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

Type: Bug Priority: Major - P3
Reporter: Pranjal Vatsa Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 10, 32 bit, Visual Studio 2017, .net core 2.2



 Description   

Trying to setup a built and working .Net Core 2.2 Web application on my system. Have installed Mongo DB 4.0.

Getting a run time error. Below is the exception thrown
 
{{System.TimeoutExceptionHResult=0x80131505Message=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 : "Unknown", State : "Disconnected", Servers : [{ ServerId: "

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

", EndPoint: "Unspecified/localhost:27018", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. --> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No connection could be made because the target machine actively refused it [::1]:27018 at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__271_0(IAsyncResult iar)-- End of stack trace from previous location where exception was thrown — at MongoDB.Driver.Core.Connections.TcpStreamFactory.ConnectAsync(Socket socket, EndPoint endPoint, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateStreamAsync(EndPoint endPoint, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)--- End of inner exception stack trace — at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2019-08-09T15:11:24.7506020Z" }] }.Source=MongoDB.Driver.CoreStackTrace:}}

{{}}

Have already tried appending '?connect=replicaSet' to the connection string as suggested here : https://groups.google.com/forum/#!topic/mongodb-csharp/O460OHiFjZs

 

Connection string:

{{"ConnectionStrings":

{"DefaultConnection": "mongodb://localhost:27017,localhost:27018/?rs=SpeQue"}

,}}{{}}



 Comments   
Comment by Esha Bhargava [ 26/Aug/19 ]

pranjalvatsa86@gmail.comThanks for your report. Please note that this project is for reporting bugs or feature suggestions for the driver. For MongoDB-related support discussion please post on the [mongodb-user group|http://groups.google.com/group/mongodb-user] or [Stack Overflow with the mongodb tag|http://stackoverflow.com/questions/tagged/mongodb]. A question like this involving more discussion would be best posted on the mongodb-users group. 

Comment by Pranjal Vatsa [ 09/Aug/19 ]

2019-08-10T03:30:19.662+0530 I NETWORK [conn719] received client metadata from 127.0.0.1:54745 conn719: { driver:

{ name: "mongo-csharp-driver", version: "2.8.1.0" }

, os: { type: "Windows", name: "Microsoft Windows 10.0.17134", architecture: "x86_64", version: "10.0.17134" }, platform: ".NET Core 4.6.27817.03" }
2019-08-10T03:34:23.113+0530 I NETWORK [conn719] end connection 127.0.0.1:54745 (0 connections now open)

above two lines are from mongod.log.. as can be seen the connection is established but it soon ends with the exception thrown

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