【发布时间】:2016-12-14 18:23:52
【问题描述】:
我尝试从我的 Windows 客户端连接到远程 PostgreSQL 服务器。 当我使用“Dbeaver”连接到数据库时,我必须填充网络连接(SSH)并且连接正常。
我正在 VB.NET 中开发一个必须连接到数据库的应用程序,但我无法使其成为可能。
我使用 Devart dll 连接到数据库和 Renci.SshNet dll 连接到服务器。
我已经设法连接到服务器,显然是通过 SSH,因为日志说但是当我尝试连接到 DDBB 时,它会引发错误:
no hay una línea en pg_hba.conf para "xx.xx.xx.xxx", usuario "xxx", base de datos "xxxx", SSL inactivo
连接代码如下:
Dim connectionInfo As New PasswordConnectionInfo(IP, USER, PASS)
connectionInfo.Timeout = TimeSpan.FromSeconds(30)
client = New SshClient(connectionInfo)
client.Connect()
Dim portFwld As New ForwardedPortLocal("127.0.0.1", Convert.ToUInt32(PORT_SSH), IP, Convert.ToUInt32(5432))
client.AddForwardedPort(portFwld)
portFwld.Start()
Log(client.IsConnected)
Log(portFwld.IsStarted)
client.IsConnected = true 和 portFwld.IsStarted = true
错误在这里(打开时):
Dim myConnection As PgSqlConnection = New PgSqlConnection()
Try
myConnection.ConnectionString = "Server=" & IP & ";Port=5432;Database=" & BBDD_Postgre & ";User Id=" & USER & ";Password=" & PASS & ";"
myConnection.Open()
我尝试了很多组合,但没有一个是有效的,我不知道还能看什么,我迷路了。我想如果“Dbeaver”可以从我的电脑连接,为什么我的应用程序不能?如果没有“Dbeaver”运行,为什么我的服务器必须在 pg_hba.conf 中添加我的 IP?
【问题讨论】:
标签: .net postgresql ssh tunneling