- Home /
Unity/C#/MongoDB - attempt to read past the end of the stream?
Hello, I'm at a loss on how to handle this. I've tried for 2 days and can't figure out how to handle this. I've asked everywhere and looked at all the resources I could find available on this but none came up with any useful information. I don't even know what this error even means and I'm at my end for how to fix this. I don't even know if this is a script or database problem let alone how to go about any sort of solution to it.
Basically I'm creating a game in unity and to get what I require I decided to hit the books on creating databases, which so far so good until I get this error when testing out the code
EndOfStreamException: attempt to read past the end of the stream
Here is the block of code that helps it run, though I'm just assuming, I don't think it is the code, it seems more or less something to do with the database just judging by the multiple debugging outputs and changes I have created until I called it quits and decided to ask for help.
private const string username = "Insert Username here";
private const string password = "Insert Password here";
private const string MONGO_URL = "mongodb://" + username + ":" + password + " @clusterName-shard-00-02-xxxxx.mongodb.net:27017";
private const string DATABASE_NAME = "test";
private MongoClient client;
private MongoServer server;
private MongoDatabase database;
private MongoCollection accounts;
public void Init()
{
client = new MongoClient(MONGO_URL);
server = client.GetServer();
database = server.GetDatabase(DATABASE_NAME);
accounts = database.GetCollection("accounts");
}
public bool InsertAccount(string username, string password, string email)
{
Model_Account newAccount = new Model_Account();
newAccount.userName = username;
newAccount.password = password;
newAccount.email = email;
Debug.Log(newAccount.userName);
Debug.Log(accounts);
accounts.Insert(newAccount); //Where the error happens.
return true;
}
As you can see, I have a insertaccount function that at the moment is called on Start(). Model_Account for the record is only holding values that will be added to the database, doesn't hold anything but that. I'm really at a loss on what to do with this error so if someone could help with this I'd be grateful.
The error if you didn't notice is on accounts.Insert() but that's all the information I can give about that because that function is on the mongoDB plugin API. I don't even know what this error means or where to go about finding the resource that will help me so I'm hoping I can get a answer soon so I can move forward on my game production.
Your answer
Follow this Question
Related Questions
Trying to find the highest number than add it to itself. 2 Answers
Cannot reduce localScale to 0 1 Answer
How do i make the player to walk to where the mouse cursor position was clicked ? 0 Answers
How can i show the ui button only when pressing on the escape key ? 2 Answers
MissingReferenceException Problem 0 Answers