[CSHARP-754] Driver could not reconnect to the server after socket exception, had to recycle application pool. Created: 10/Jun/13  Updated: 20/Mar/14  Resolved: 10/Jun/13

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

Type: Bug Priority: Major - P3
Reporter: Stefano Ricciardi Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Client: Windows .NET 4, Server: Linux (CentOS).


Issue Links:
Duplicate
duplicates CSHARP-654 Client does not recover automatically... Closed

 Description   

After a network error occurred between one of our web servers and Mongo ("SocketException: No such host is known") all subsequent requests to the replica set from that particular web server failed with the same error, while other web servers worked perfectly fine. After recycling the IIS application pool no more connection errors have been reported.

Our database object is a singleton. We did a quick test pointing to a single-instance server (no replica set) and we were not able to reproduce the issue after stopping and restarting the mongo server (after mongo restarted the drivers were able to contact Mongo again without recycling the application pool). We think this might have something to do with the replica set.

Stack trace:

2013-06-10 12:52:17,118 WARN -
MongoDB.Driver.MongoConnectionException: Unable to connect to a member of the replica set matching the read preference Primary: No such host is known. ---> System.Net.Sockets.SocketException: No such host is known
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
at MongoDB.Driver.MongoServerAddress.ToIPEndPoint(AddressFamily addressFamily) in C:\build\mongo-csharp-driver\Driver\Core\MongoServerAddress.cs:line 196
at MongoDB.Driver.MongoServerInstance.GetIPEndPoint() in C:\build\mongo-csharp-driver\Driver\Core\MongoServerInstance.cs:line 339
at MongoDB.Driver.Internal.MongoConnection.Open() in C:\build\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 368
at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, WriteConcern writeConcern, String databaseName) in C:\build\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 559
at MongoDB.Driver.Internal.MongoConnection.RunCommand(String databaseName, QueryFlags queryFlags, CommandDocument command, Boolean throwOnError) in C:\build\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 425
at MongoDB.Driver.MongoServerInstance.Ping(MongoConnection connection) in C:\build\mongo-csharp-driver\Driver\Core\MongoServerInstance.cs:line 695
at MongoDB.Driver.MongoServerInstance.Connect() in C:\build\mongo-csharp-driver\Driver\Core\MongoServerInstance.cs:line 480
at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.<>c_DisplayClassd.<ConnectInstance>b_c(Object _) in C:\build\mongo-csharp-driver\Driver\Internal\MultipleInstanceMongoServerProxy.cs:line 415
— End of inner exception stack trace —
at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.ThrowConnectionException(ReadPreference readPreference) in C:\build\mongo-csharp-driver\Driver\Internal\MultipleInstanceMongoServerProxy.cs:line 509
at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.Connect(TimeSpan timeout, ReadPreference readPreference) in C:\build\mongo-csharp-driver\Driver\Internal\MultipleInstanceMongoServerProxy.cs:line 224
at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.ChooseServerInstance(ReadPreference readPreference) in C:\build\mongo-csharp-driver\Driver\Internal\MultipleInstanceMongoServerProxy.cs:line 159
at MongoDB.Driver.MongoServer.AcquireConnection(MongoDatabase database, ReadPreference readPreference) in C:\build\mongo-csharp-driver\Driver\Core\MongoServer.cs:line 1058
at MongoDB.Driver.MongoCursorEnumerator`1.AcquireConnection() in C:\build\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 299
at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst() in C:\build\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 312
at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext() in C:\build\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 230
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)



 Comments   
Comment by Craig Wilson [ 10/Jun/13 ]

Hi Stefano,
This is a known issue with versions 1.6 - 1.7 (CSHARP-654). It has been fixed in the 1.8 version. Upgrading your driver version will fix this problem.

Sorry about the trouble.
Craig

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