Jump to content

[Solved] MongoDB and Node.js


Recommended Posts

Hey! 

I've tried working through this as much as possible before wasting your time here, but I'm at a loss. I was trying to set up MongoDB Atlas alongside php to dynamically load what's essentially just a directory with some filters. Nothing memory-heavy, but a few hundred entries long with ~12 fields each, and I already have it in csv format, so I was thinking that it would just be really nice to not have to deal with typing everything in on static pages. Anyways, I have everything connected and working on my local machine (connected to Atlas), but was running into a wall getting the Mongodb drivers for PHP installed on HelioHost (or even finding out if it's possible in the first place). I had also tried using the composer.json file to install the dependencies, and while it brought up the package that would work, it couldn't install it due to the php.ini file and missing MongoDB extension. 

Then, after spending all night trying various versions of PHP, I kind of threw in the towel and thought I'd just go with what I wanted to do in the first place and utilize Node.js (or more specifically React/Next.js). But I'm running into similar issues of just not seeing what I'm missing/what needs done. I've read through the documentation and created the app.js file (with provided code), scrubbed this forum, and have looked on most every other forum that I can find. The parts around node.js in the Heliohost documentation mention/show some settings that I just don't see anywhere in my Plesk control panel. Same for PHP. I can change the version (as previously mentioned), but is there a way to install drivers/extensions beyond what's already shown in phpinfo?  I'm hoping that I'm just missing something simple or perhaps it's just something that I need to ask for/about. 

So 2 questions:
1. Is it possible to use PHP with Mongodb's cloud database on here? 
2. What's needed in order for the Node.js settings to show up? 


 

Link to comment
Share on other sites

Node.js should be there as an option under the development tools section, though I believe Plesk can hide it in certain views. Try changing your view settings in Plesk. Also, be careful with node as its a very common cause of load suspensions (notably for memory use).

 

You can't install extensions or modify the PHP configuration on the shared hosting yourself by design (beyond the few options you see in plesk). Krydos may be able to add support for connecting to external mongo databases if it won't affect anything else, but there's a possibility that it will require a VPS instead. What exactly do you need, a PDO driver for Mongo? What version of PHP are you using?

Link to comment
Share on other sites

You're right! I had somehow clicked (what felt like) everywhere, but hadn't used the search function that's built into the dashboard. Typed in Node and voila! I admit that I am a bit weary about using it due to the load suspensions, but that's still a big question answered! 

As for the Mongo database portion, I admit that I'm not quite sure, just due to not being certain on the terminology. With Mongo, I just needed some way to access/interact with the Mongo database and for php, it requires the driver extension. That said, they do offer other ways to form that connection that don't rely on PHP, so I'm open to trying those if it's not possible without a VPS. I'm currently using PHP v8.2.15, though I was using 8.1 last night while testing. That part is a bit more flexible as the MongoDB drivers can be v1.13 to v1.17 and support PHP 8.1 to 8.2. 

 

Link to comment
Share on other sites

Just tested with Node.js and it was able to start and seemed to work okay. Displayed the default message and all, but it's a bit beyond what I'm experienced with at the moment, if I'm being honest (especially in regards to connecting it to MongoDB Atlas).  I don't want to break the site or get my account suspended, so for now I'll keep some semblance of hope that the Mongo drivers are a possibility.


I know that I can implement them on a very case-by-case basis with php and keep memory usage lower and give myself some time to learn Node. 

Link to comment
Share on other sites

Was honestly more of the interface and NoSQL combined with the ability to easily change the add data from multiple devices/locations than anything.

The portion of the site that I'm making is a list of projects and organizations and I'm updating it all the time and getting submissions pretty often when I'm out and only have an iPad or my phone available.  That and I've been pretty frustrated with how quickly I get logged out/timed out of everything on the Helionet, so it was a nice added bonus that I could just have the MongoDB Compass app.

 That all said, I've been working on it today and I think I'll be able to make do with MariaDB if it's not feasible to connect Mongo. None of the reasons for not wanting to use MariaDB are really big dealbreakers. Just multiple aesthetic things and little everyday ease-of-access aspects. 

Link to comment
Share on other sites

29 minutes ago, thestreetartlist said:

That and I've been pretty frustrated with how quickly I get logged out/timed out of everything on the Helionet, so it was a nice added bonus that I could just have the MongoDB Compass app.

This is likely because your IP keeps changing, and is very common if you're on cellular internet. Using a VPN will probably solve this issue for you.

Link to comment
Share on other sites

The reason I ask is because I've been considering providing MongoDB hosting on our own servers so people don't have to use remote databases. It seems to be a pretty popular database system, but I haven't used it at all myself. I suspect it would be a fairly sought after feature if we were able to start supporting it. Installing it and maintaining it would definitely be a learning experience for me and I love learning new things, especially stuff related to hosting and computers in general.

As far as getting logged out, if it happens in less than a minute or so it's probably because your IP address is changing. Plesk hates it when your IP changes and it logs you out, sometimes only after a few seconds. If you get logged out after 30 minutes or so, then that's just by Plesk's design. If you install PhpMyAdmin or Adminer in your httpdocs folder you can set the logout timer to whatever you want. For example, https://stackoverflow.com/a/64480479 https://stackoverflow.com/a/11858297

  • Like 1
Link to comment
Share on other sites

6 minutes ago, Krydos said:

The reason I ask is because I've been considering providing MongoDB hosting on our own servers so people don't have to use remote databases.

Ah, that makes sense. Yeah, for me, it's just more flexible and easier to deal with. Plus easier to connect to other destinations/sites, despite needing to initially change settings so Mongo doesn't IP limit. 

 

9 minutes ago, wolstech said:

This is likely because your IP keeps changing, and is very common if you're on cellular internet. Using a VPN will probably solve this issue for you.

It's not due to cellular as it's happening on my desktop. Not sure how long it takes. It's just frustrating as when it logs me out, I can't just re-log in and refresh the database or it shows an error. I needed to close it and reopen it from Plesk. I got around it for now by just using the HeidiSQL desktop app. Good to know that I can do the PhpMyAdmin/Adminer solution, though. I'll check that out now. 

Edited by thestreetartlist
Link to comment
Share on other sites

  • Krydos changed the title to [Solved] MongoDB and Node.js

Thanks! I'll mess with it more later. I tried re-setting up what I had the other day and just run into an error about an inability to connect. I'm using the same credentials and file as the other day, so I'm not sure what could be causing it. That said, super tired so it's possible that it's just user error. I'll give it a shot again in the coming days when I have a moment. 

Link to comment
Share on other sites

Tried again this morning. Checked and rechecked credentials on Mongo's side, reinstalled and updated the MongoDB libraries, adjusted the whitelisted IP addresses to allow all without restriction, and still get this error: 

 

Quote

No suitable servers found (`serverSelectionTryOnce` set): [connection closed calling hello on 'ac-uzqutet-shard-00-02.gubnimt.mongodb.net:27017'] [connection closed calling hello on 'ac-uzqutet-shard-00-01.gubnimt.mongodb.net:27017'] [connection closed calling hello on 'ac-uzqutet-shard-00-00.gubnimt.mongodb.net:27017']



Not really sure what else to do. Most troubleshooting that I see refers to using the terminal and I'm otherwise at a loss. Any idea or prior experience with other users that could help? I read another post that mentioned a problem with port 27017, but that seemed to be resolved at that time. 

Link to comment
Share on other sites

  • wolstech changed the title to [Krydos] MongoDB and Node.js

I didn't forget anything, thestreetartlist never mentioned what port it was running on, so I just assumed it was some already open port. Anyways, outbound 27017 has been opened on Johnny. Does it work now?

  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...