unity-mongodb icon indicating copy to clipboard operation
unity-mongodb copied to clipboard

Error to connect

Open lipecss opened this issue 5 years ago • 0 comments

thats my code, when I play my game on Unity im getting this error:

MongoConnectionException: Unable to connect to a member of the replica set matching the read preference Secondary MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.ThrowConnectionException (MongoDB.Driver.ReadPreference readPreference) (at <6da29fc855c44d33ad78b3e27475ff27>:0) MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.Connect (System.TimeSpan timeout, MongoDB.Driver.ReadPreference readPreference) (at <6da29fc855c44d33ad78b3e27475ff27>:0) MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.ChooseServerInstance (MongoDB.Driver.ReadPreference readPreference) (at <6da29fc855c44d33ad78b3e27475ff27>:0) MongoDB.Driver.MongoServer.AcquireConnection (MongoDB.Driver.ReadPreference readPreference) (at <6da29fc855c44d33ad78b3e27475ff27>:0) MongoDB.Driver.MongoCursor1+MongoCursorConnectionProvider[TDocument].AcquireConnection () (at <6da29fc855c44d33ad78b3e27475ff27>:0) MongoDB.Driver.Operations.QueryOperation1[TDocument].GetFirstBatch (MongoDB.Driver.Operations.IConnectionProvider connectionProvider) (at <6da29fc855c44d33ad78b3e27475ff27>:0) MongoDB.Driver.Operations.QueryOperation1[TDocument].Execute (MongoDB.Driver.Operations.IConnectionProvider connectionProvider) (at <6da29fc855c44d33ad78b3e27475ff27>:0) MongoDB.Driver.MongoCursor1[TDocument].GetEnumerator () (at <6da29fc855c44d33ad78b3e27475ff27>:0)

`using System.Collections.Generic; // Lists

using MongoDB.Bson; using MongoDB.Driver; using MongoDB.Driver.Builders; using MongoDB.Driver.GridFS; using MongoDB.Driver.Linq;

public class mongo : MonoBehaviour { string connectionString = "my string connection";

void Start()
{
    var client = new MongoClient(connectionString);
    var server = client.GetServer();
    var database = server.GetDatabase("Discord");
    var playercollection = database.GetCollection<BsonDocument>("users");
    Debug.Log("Conexao Realizada com Sucesso");

    foreach (var document in playercollection.FindAll())
    {
        Debug.Log("4. SELECT ALL DOCS: \n" + document);
    }
}`

lipecss avatar Jul 15 '19 20:07 lipecss