How to add retry in MongoDb C# driver? -


sometimes receivebufferasync in find method throws:

mongodb.driver.mongoconnectionexception: exception occurred while receiving message server.
---> system.io.ioexception: unable read data transport connection: connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond.
---> system.net.sockets.socketexception: connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond

i think fixed retry in method:

mongodb.driver.core\core\connections\binaryconnection.cs  private async task<ibytebuffer> receivebufferasync() {             try             {                 var messagesizebytes = new byte[4];                 await _stream.readbytesasync(messagesizebytes, 0, 4, _backgroundtaskcancellationtoken).configureawait(false);                 var messagesize = bitconverter.toint32(messagesizebytes, 0);                 var inputbufferchunksource = new inputbufferchunksource(bsonchunkpool.default);                 var buffer = bytebufferfactory.create(inputbufferchunksource, messagesize);                 buffer.length = messagesize;                 buffer.setbytes(0, messagesizebytes, 0, 4);                 await _stream.readbytesasync(buffer, 4, messagesize - 4, _backgroundtaskcancellationtoken).configureawait(false);                 _lastusedatutc = datetime.utcnow;                 buffer.makereadonly();                 return buffer;             }             catch (exception ex)             {                 var wrappedexception = wrapexception(ex, "receiving message server");                 connectionfailed(wrappedexception);                 throw wrappedexception;             } } 

but can't find way. new stream here?


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -