0

I'm trying to connect my c# application with openshift database. But I get this exception on the conn.Open()

Eccezione =>  MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
   in MySql.Data.MySqlClient.NativeDriver.Open()
   in MySql.Data.MySqlClient.Driver.Open()
   in MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   in MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
   in MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   in MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   in MySql.Data.MySqlClient.MySqlPool.GetConnection()
   in MySql.Data.MySqlClient.MySqlConnection.Open()

this is my method:

 public void connect()
    {
        string connStr = @"Server=test-lound.rhcloud.com;Port=3306;Database=test;Uid=XXXX;Pwd=YYYY;";
        MySqlConnection conn = new MySqlConnection(connStr);
        
        try
        {
            Console.WriteLine("Connecting to MySQL...");
            conn.Open();
            Console.WriteLine("Connection successfull !");

            conn.Close();
            Console.ReadLine();
        }
        catch (Exception ex)
        {
            Console.WriteLine("Eccezione =>  " + ex.ToString());
        }
        Console.WriteLine("Done.");
    }

what I doing wrong? Is possible establish a connection with a openshift database through c# client application?

Edit: I found this document here that describes an SSH tunnel requirement. Perhaps that is necessary.

Community
  • 1
  • 1
Salvatore Fucito
  • 255
  • 1
  • 14

1 Answers1

1

Alright, I finally worked it end-to-end but it is Mysql Workbench via ssh tunnel. It is a requirement for openshift as it is a PaaS sitting on top of IaaS AWS (Amazon EC2). So for the developer it is no problem. For the end-user, without a ssh-rsa public keypair, it won't work, as I see it.

A few good links to capture along the way: A site for quick and easy 2048bit ssh-rsa key gen. A doc for putty and puttygen. The doc for tunnel setup (critical); look what dgreen wrote.

A solution is to either supply a keypair with the app, and tweak your C# accordingly for the tunnel, or to go with AWS EC2 IaaS and it is a snap. AWS has a Free-tier for a year. I could set that up easily, as that is where I am most familiar. But I must say I do like Openshift and its PHP front end.

Drew
  • 24,851
  • 10
  • 43
  • 78
  • refer to the 2 answers to [this](http://stackoverflow.com/questions/10806799/how-to-connect-to-mysql-from-c-sharp-over-ssh) question. – Drew Aug 09 '15 at 23:47
  • I actually worked with Putty to read the content FTP. I got to work with sockets with Java but with C # it is still new to this language now I am seriously in trouble. I see what I can combine, thanks anyway for the help. – Salvatore Fucito Aug 10 '15 at 08:24
  • In the future, this application will be distributed desktop, I may have your help to make this code? If you are willing to help me in private and make a tutorial along to other Skype users are available: John Carter (Avatar yellow with a picture of breaking bad) – Salvatore Fucito Aug 10 '15 at 10:08
  • Sure. You can find my contact info off my profile page. I want to put a Screencast vid together on how to configure – Drew Aug 10 '15 at 11:50
  • I have been messing around with the http://sshnet.codeplex.com/ project / library. I will share some c# stuff once I bang out an example. – Drew Aug 10 '15 at 12:01
  • Thanks, I've contacted you on gmail with Ferven account, let me updated. – Salvatore Fucito Aug 10 '15 at 12:29