baoliay2008 / lccn_predictor

LeetCode Contest Rating Prediction
https://lccn.lbao.site
MIT License
570 stars 22 forks source link

failed to start mongodb #10

Closed Kabir1506 closed 10 months ago

Kabir1506 commented 1 year ago

getting this error while executing step number 8 from this.. | ERROR | app.db.mongodb:start_async_mongodb:100 - Failed to start mongodb. error=Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed'} pls help `1-git clone git@github.com:baoliay2008/lccn_predictor.git 2-cd lccn_predictor

write your mongodb environment config

3-cp config.yaml.template config.yaml 4-vi config.yaml

5-python3.10 -m virtualenv venv/ 6-source venv/bin/activate

7-pip3 install -r requirements.txt

8-python main.py 9-uvicorn api.entry:app --host 0.0.0.0 --port 55555`

baoliay2008 commented 1 year ago

Hello, @Kabir1506. Just a gentle reminder that it's necessary to install MongoDB before proceeding. You can find detailed instructions on how to do this by referring to the MongoDB Installation Tutorials. Version 5.0+ should work.

Kabir1506 commented 1 year ago

Hi @baoliay2008 , I have already installed 6.0.5 version

baoliay2008 commented 1 year ago

Please check your config.yaml file, for example

mongodb:
  ip: 192.168.1.12
  port: 27017
  username: testing
  password: 'password'
  db: testing

You may verify the authentication configuration of your MongoDB instance by using the ip, port, username, password and db information provided above with the command of ⏎ mongosh --host 192.168.1.12 --port 27017 -u "testing" -p "password" --authenticationDatabase "testing"

Kabir1506 commented 1 year ago

Now getting this error: ERROR | app.db.mongodb:start_async_mongodb:100 - Failed to start mongodb. error=quote_from_bytes() expected bytes. The mongodb server is up..

baoliay2008 commented 1 year ago

Now getting this error: ERROR | app.db.mongodb:start_async_mongodb:100 - Failed to start mongodb. error=quote_from_bytes() expected bytes. The mongodb server is up..

It seems that the issue might still be with the config.yaml file. My assumption is that you might have entered a numeric password without enclosing it in quotes.

For instance, if your MongoDB password configuration is password: 20230403, the YAML parser will interpret it as a number data type instead of a string. In this case, kindly try using password: "20230403" instead, which should ensure that it gets parsed as a string data type.

Kabir1506 commented 1 year ago

I have started the mongo server with this command mongod --port 27017 --dbpath C:\MongoDB\data\db and have commented username password in config.yml mongodb: ip: 127.0.0.1 port: 27017 db: lccn

baoliay2008 commented 1 year ago

Understood, you didn't write the username and password field in config.yml, I see.

To address this, I would recommend updating your config.yml file to include these two fields because it's recommended that you create a separate user account specifically for MongoDB usage, as outlined in the MongoDB Manual.

Alternatively, if you don't want to create a user then you could modify the code to fix the issue. In your case, deleting L48-L49 and changing L52 from f"mongodb://{username}:{password}@{ip}:{port}/{db}", to f"mongodb://{ip}:{port}/{db}", might resolve the issue. However, this is just a suggestion and you are welcome to try it out.

Kabir1506 commented 1 year ago

cool thanks alot. Now working on front-end steps

Kabir1506 commented 1 year ago

@baoliay2008 I don't see any dummy contest data in front-end. Is there a way to load dummy data to test and work upon.

baoliay2008 commented 1 year ago

In the next version, I will include some dummy data.

However, for now, you can still test the functionality by running a very old contest (this is only recommended for temporary testing purposes as the results will be completely inaccurate). To do this, kindly add the following two lines after main.py L13:

    from app.core.schedulers import composed_predict_jobs
    await composed_predict_jobs("biweekly-contest-1")