2

I am developing a desktop app and I want to store data in hosted database like MySQL/MongoDB. I know one solution is using webservice to manipulate db. I am wondering is there a way to connect desktop app with hosted db directly.

I am using OpenShift I know I can use port-forward to do this. But it's unpractical to open port forward every time for every PC. So is a way simply like this:

mongoose.connect('mongodb://user:pass@host:port/db');

I tried this but I got 'connect refused' or 'connect not found' errors. OpenShift doesn't allow external access to database directly because security issues, right? Then how could I do it without port-forward?

Also I read some articles about SSH, is it possible to use SSH to access db directly when desktop app is launched?

Thanks for any suggestion.

He Zhang
  • 137
  • 2
  • 16
  • @BK435 MongoDB. Actually I want to do it also for MySQL in another project – He Zhang Aug 11 '15 at 22:28
  • I wrote [this](http://stackoverflow.com/a/31909044/1816093) up for that gent, worked him onto AWS free tier (I love dev ops). Openshift from Redhat sits on top of AWS anyway. Removes the ssh scenario, and the need to get ssh.net tunnel going first. So, he has the ability to get to port 3306 if he wants, else it is behind the firewall and he goes PHP all the way. Openshift is nice though ... a fantastic PaaS. – Drew Aug 11 '15 at 22:31
  • @Drew It seems like I need to make SSH connection first then try to connect with db. Let's me search if there is such approach for node first. Thanks – He Zhang Aug 11 '15 at 22:52
  • sure thing. basically on AWS / Azure you can have whatever you want (any db server). As you know, it is highly uncommon to expose a database directly to the net. It can be protected behind SSH server. For ssh tunnels the action is all with [SSH.NET](https://sshnet.codeplex.com/) as SharpSSH sorta fell out of fashion. good luck :> – Drew Aug 11 '15 at 22:54
  • @Drew I agree with you. I may just go with webservice approach since security issue. So overall, what's the most common solution for this? exchange data between db server and desktop app. – He Zhang Aug 11 '15 at 23:02
  • I will answer it this way. Based on [this](https://wiki.wireshark.org/SampleCaptures#MySQL_protocol): I would never connect without the option for SSH tunnels on the internet. As for what is common practice, probably a sorry state of lax security, **idk**. With all the talk here on sql injection in php, I wonder the % of login.php files that connect with SSL/TLS :> ... I have always been a PKI security socket guy. I love the ability to create a socket server for a client doing just about anything, without worrying that GoDaddy etc will getting in our way. So it is AWS/Azure or nothing. – Drew Aug 11 '15 at 23:07

1 Answers1

1

I don't think OpenShift is going to be a good fit for what you are trying to do, unless you decide to build a service layer between your desktop app and the database. It sounds like you are looking for a Database As A Service. You mentioned both MongoDB and MySQL. MongoLab is a good MongoDB DBaaS option. For other databases like MySQL, PostgreSQL and several others you could look at Amazon RDS.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • Thanks for suggestions. I tried MongoLab as DBaaS and It works pretty well. I can access db via mongoose.connect('mongodb://user:pass@host:port/db'); directly from my desktop app. I am wondering is this safe and secure? – He Zhang Aug 12 '15 at 14:22
  • I don't think I would consider it "safe and secure" at this point. They have SSL connections in beta right now, which would be secure. – Mark B Aug 12 '15 at 14:24