-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 2.11.0-beta1
-
Component/s: Connectivity
-
None
-
Environment:Docker debian
Hi,
I'm in the process of updating several applications to .NET Core and after updating the MongoDB driver to version 2.11.0-beta1 our deploys started to fail.
After quite a lot of trial and error I found a StackOverflow question from 19 days ago detailing the same error we were getting:
The only answer mentions that manually resolving the server hostnames fixes the error. I've tried and indeed fixed our deploy issues.
The same answer mentions that this issue was fixed a long time ago, is this a regression?
Thanks,
Jose
Error:
---> System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector\{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatncyRange = 00:00:00.0150000 } }. Client view of cluster state is \{ ClusterId : "1", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/<SERVER HOSTNAME>:27017" }", EndPoint: "Unspecified/<SERVER HOSTNAME>:27017", ReasonChanged: "Heartbeat", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Diver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.PlatformNotSupportedException: Sockets on this platform are invalid for use after a failed connection attempt. at System.Net.Sockets.Socket.ThrowMultiConnectNotSupported() at System.Net.Sockets.Socket.BeginConnect(String host, Int32 port, AsyncCallback requestCallback, Object state) 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)
Workaround:
var servers = new List<MongoServerAddress>(); // Resolve hostnames foreach (var server in mongoDbSettings.Servers) { // hostname:port var parts = server.Split(':'); var address = Dns.GetHostAddresses(parts[0]) .FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork); servers.Add(new MongoServerAddress(address.ToString(), int.Parse(parts[1]))); } var mongoClientSettings = new MongoClientSettings { Servers = servers };
- is duplicated by
-
CSHARP-3126 [Cosmos DB] Current beta breaks connection on linux hosts
- Closed
- is related to
-
CSHARP-2953 Check TcpStreamFactory methods when targetting netstandard2.0
- Closed