#Changed to a VPS and now cant access mongodb

98 messages · Page 1 of 1 (latest)

quaint fernBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
uneven blade

The IP of your VPS needs to be on your Atlas instance's allowlist afaik

deft flame

to the schemas

const UserProfile = require("../../models/player")
userProfile = await UserProfile.findOne({ discordId: discorid });
                                
MongooseError: Operation playerschemas.findOne() buffering timed out after 10000ms 

and ive set this in mongodb, so that every ip can access it

ivory zealot
deft flame

no but ill do it wait

deft flame

i did this

but why cant the other codes do? all i have did is switch to a vps and put the files over there

before the vps it all worked no errors

ivory zealot
deft flame

if im right, do you mean something like this?

ivory zealot
deft flame

i would do this to find a profile

ivory zealot
deft flame

ignore the exp

ivory zealot
deft flame

Yea, you have no index for that schema.
What is discordId, how is it different to userId?

deft flame

also i can use the findone in my server.js code but not in the other ones, thats weird

ivory zealot
ivory zealot
deft flame

still get the same error

MongooseError: Operation playerschemas.findOne() buffering timed out after 10000ms

i got this error, since ive switched my bot to the VPS

and from the server.js code i can use the .findOne()

ivory zealot

But when you tried the "any" find one it worked fine.
So it's got to be a speed problem.

Can you explore the DB in Atllas I assume and make sure tjhe Index has applied

deft flame

but i cant create a profile because the findOne is causing problems

i can use the findOne in the server.js file but not in other code ?

and why? i dont know

ivory zealot
deft flame

the schema is in the models folder and theres a file called player

and the command is in, commands > verification > verify.js

ivory zealot

Well the location of the file shouldn't matter

deft flame

ive ran this code and it worked, but the command cant

ivory zealot
deft flame
ivory zealot
deft flame

and the other files should be able to use the findOne then

this is only since ive switched to the VPS, if i run them on my computer they work all

i created a new file to test it and it works

but why cant the command use it ???

ivory zealot
ivory zealot
deft flame yes

So the non-server files "can't use it"
Did you try swapping or making a findOne(}} to see if it resolves at all on them.

deft flame

but the command which im trying to use cant

ivory zealot

Ok so everything on the server works fine.
It's just the bot's logic that can't.

But they're run by two different initializations like you said, so the bot's code will also need to connect to the DB, which I assume its doing

deft flame

i didnt change the command since it worked, and now i switched to the vps and it doesnt work anymore

ivory zealot

Can you share the command file?

deft flame

do i just send u the part of it where it tries to do the "findOne"?

or the whole

ivory zealot
digital thicketBOT

To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.

deft flame

okay

ivory zealot
ivory zealot

So yea the code looks fine, and you tried just putting a find any and it worked in this command yea?
(sorry if already asked, just re-confirming)

deft flame

@ivory zealot

ive replaced the command code of a older version

and it seems to work but

i get this error:
TypeError: userProfile.save is not a function

and i think the issue was because the "await" did somtehing

ivory zealot
ivory zealot
deft flame
deft flame
ivory zealot
deft flame
ivory zealot

Your command function "callback" is async, there should be no reason you can't use await

deft flame

ill add back the await and ill check if it still works

TypeError: userProfile.save is not a function
and this came new btw

and yeah, i cant use findOne once i add back await

ivory zealot

So here's the problem, you need to resolve promises to ever get data from them, so if adding await causes an issur you must be using save incorrectly.

Also bare with me, I'm on a train

deft flame
deft flame
ivory zealot

It really shouldn't, least not how you expect.

I see you have

const userProfile = <findOne>;
if (userProfile) {
  //do stuff as record exists
}

Problem is, a unresolved promise is truthy, so even for a missing user profile, it'll run the if