连接到OpenShift服务
问题描述:
我刚刚进入OpenShift,请耐心等待。我在我的域中设置了一个MySQL数据库,并且能够从phpMyAdmin页面添加和删除项目。我现在想在我的机器上创建一个应用程序,并且只在我的机器上连接到数据库,并且能够具有读/写访问权限。我已经为这个用户设置了一个权限集,并为C#编写了一个表单。我已经执行了以下内容:连接到OpenShift服务
rhc port-forward --app <my application name>
事后,我收到如下:
W:\>rhc port-forward --app <my application name>
DL is deprecated, please use Fiddle
Checking available ports ... done
Forwarding ports ...
Only one usage of each socket address (protocol/network address/port) is
normally permitted. - bind(2) while forwarding port 8080. Trying local port 8081
To connect to a service running on OpenShift, use the Local address
Service Local OpenShift
httpd 127.0.0.1:8080 => 127.3.223.1:8080
httpd 127.0.0.1:8081 => 127.3.223.3:8080
mysql 127.0.0.1:3306 => 127.3.223.2:3306
Press CTRL-C to terminate port forwarding
因此,当我重新回到C#,我有下面的代码行:
conn = new SqlConnection("user id="+tbUser.Text+";password="+tbPass.Text+";server=127.0.0.1:3306;database=<my application name>");
conn.Open();
但我得到.Open()函数的错误,说它找不到服务器或数据库。我对正在发生的事情不知所措。
编辑:我想我还不如添加如果在所有有用的错误消息:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
答
您应该使用,而不是IP地址的应用程序URL,你列出的每个地址是loopback interface,不代表您的应用程序网址。
尝试使用http://yourappdomain.rhcloud.com:3306