.net - Initialize MongoClient with MongoClientSettings in C# -


i'm trying initialize mongoclient mongo 2.0 driver follows:

mongoclientsettings settings = new mongoclientsettings(); settings.waitqueuesize = int.maxvalue; settings.waitqueueutimeout = new timespan(0,2,0); settings.minconnectionpoolsize = 1; settings.maxconnectionpoolsize = 25; settings.server = new mongoserveraddress("mongodb://localhost"); client = new mongoclient(settings) 

however, when try insert document code:

db = client.getdatabase("local"); col = db.getcollection<bsondocument>(collectionname); col.insertoneasync(new bsondocument().add(new bsonelement("id",bsonvalue.create(1)))).wait(); 

it doesn't anything. doesn't inserted, , no error message (although after while first chance exception of system.timeout appears in output). if initialize client with

client = new mongoclient("mongodb://localhost") 

it work , uploads document intended.

i want client able handle high write throughput, tried these settings first. did set of settings wrong or there different problem?

edit: after more testing, indeed system.timeout exception i'm getting.

i reproduce problem, in error message, there more helpful information buried somewhere in 40 lines of text:

no such host known

it turns out mongoserveraddress only expects hostname, not protocol:

settings.server = new mongoserveraddress("localhost"); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -