Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jessekayden23 · Apr 28, 2020 at 01:42 PM · scripting problemscript.database handling

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

237 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges