[CSHARP-1908] Cannot connect to remote server when running on Mono on Windows Created: 05/Feb/17  Updated: 27/Oct/23  Resolved: 02/Mar/17

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

Type: Bug Priority: Major - P3
Reporter: Bradley Landis Assignee: Robert Stam
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 mono 4.6.2



 Description   

Works fine running on Mono 4.6.2 on Ubuntu linux
Works fine running on .NET Framework on Windows

Can connect to local server when running on Mono on Windows

When connecting to a remote server when running Mono on Windows:

Unhandled Exception:
System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = WritableServerSelector, 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/ds058508.mlab.com:58508" }

", EndPoint: "Unspecified/ds058508.mlab.com:5850
8", State: "Disconnected", Type: "Unknown" }] }.
at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException (MongoDB.Driver.Core.Clusters.ServerSelectors.IServerSelector selector, MongoDB.Driver.Core.Clusters.ClusterDescription description) [0x00013] in <0763d4a07cbf42da8f075cc7041f4302>:0
at MongoDB.Driver.Core.Clusters.Cluster+WaitForDescriptionChangedHelper.HandleCompletedTask (System.Threading.Tasks.Task completedTask) [0x00009] in <0763d4a07cbf42da8f075cc7041f4302>:0
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged (MongoDB.Driver.Core.Clusters.ServerSelectors.IServerSelector selector, MongoDB.Driver.Core.Clusters.ClusterDescription description, System.Threading.Tasks.Task descriptionChangedTask, System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) [0x00021] in <0763d4a07cbf42da8f075cc7041f4302>:0
at MongoDB.Driver.Core.Clusters.Cluster.SelectServer (MongoDB.Driver.Core.Clusters.ServerSelectors.IServerSelector selector, System.Threading.CancellationToken cancellationToken) [0x00047] in <0763d4a07cbf42da8f075cc7041f4302>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = WritableServerSelector, 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/ds058508.mlab.com:58508" }

", EndPoint:
"Unspecified/ds058508.mlab.com:58508", State: "Disconnected", Type: "Unknown" }] }.
at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException (MongoDB.Driver.Core.Clusters.ServerSelectors.IServerSelector selector, MongoDB.Driver.Core.Clusters.ClusterDescription description) [0x00013] in <0763d4a07cbf42da8f075cc7041f4302>:0
at MongoDB.Driver.Core.Clusters.Cluster+WaitForDescriptionChangedHelper.HandleCompletedTask (System.Threading.Tasks.Task completedTask) [0x00009] in <0763d4a07cbf42da8f075cc7041f4302>:0
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged (MongoDB.Driver.Core.Clusters.ServerSelectors.IServerSelector selector, MongoDB.Driver.Core.Clusters.ClusterDescription description, System.Threading.Tasks.Task descriptionChangedTask, System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) [0x00021] in <0763d4a07cbf42da8f075cc7041f4302>:0
at MongoDB.Driver.Core.Clusters.Cluster.SelectServer (MongoDB.Driver.Core.Clusters.ServerSelectors.IServerSelector selector, System.Threading.CancellationToken cancellationToken) [0x00047] in <0763d4a07cbf42da8f075cc7041f4302>:0

Example code:

using System;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.IdGenerators;
using MongoDB.Driver;
using Newtonsoft.Json;

namespace ConsoleApplication1
{
internal class Program
{
public static void Main(string[] args)
{
var mongourl = "<CONNECTION STRING>";
var dbName = "<DATABASE NAME>";

BsonSerializer.RegisterIdGenerator(
typeof(string),
StringObjectIdGenerator.Instance
);

var clientSettings =
MongoClientSettings.FromUrl(new MongoUrl(mongourl));

var mongoClient = new MongoClient(clientSettings);
var db = mongoClient.GetDatabase(dbName);

var collection = db.GetCollection<TestClass>("test");
var test = new TestClass

{Name = "Test"}

;
collection.InsertOne(test);

var result = collection.Find(Builders<TestClass>.Filter.Empty).ToList();

Console.WriteLine(JsonConvert.SerializeObject(result));
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
}

public class TestClass
{
public string Id

{ get; set; }
public string Name { get; set; }

}

}



 Comments   
Comment by Robert Stam [ 02/Mar/17 ]

We no longer support running on Mono as of version 2.0.

Comment by Bradley Landis [ 06/Feb/17 ]

Problem seems to exist when running on mono installed inside Ubuntu for Windows on Windows 10 as well:

Mono JIT compiler version 4.6.2 (Stable 4.6.2.16/ac9e222 Tue Jan 3 11:48:26 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

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