Connection timeout expired

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
piopio1
Posts: 32
Joined: Thu 10 Jan 2013 23:13

Connection timeout expired

Post by piopio1 » Wed 08 Jul 2015 22:13

Hello,

I have an application that connects to a remote PostgreSQL DB via SecureBridge. The application works perfectly on my local machine but when the exact same application runs on a remote VPS server then I have the following error message: Exception SocketException in module xxxxx.exe at yyyyy Connection timeout expired

In addition, if I try to connect the same application on the VPS server to a PostgreSQL DB on the same VPS machine (local DB) I have the following error message: A connection with the server could not be established

The following are the parameters I use to connect the application to the remote DB

ScSSHChannel.SourcePort=5440
ScSSHChannel.DestPort=5432
ScSSHChannel.DestHost='DestinationHost'
ScSSHChannel.Timeout=10

PgConnection.Server='localhost'
PgConnection.Username='xxxxxxxx'
PgConnection.Password=yyyyy
PgConnection.Database='zzzzzzzz'
PgConnection.Port=5440

ScSSHClient.HostName='Remotehosting.com'
ScSSHClient.Port=7822
ScSSHClient.User='xxxxxxxxx'
ScSSHClient.Password=yyyyyyyy
ScSSHClient.Timeout=10

I tried to set ScSSHChannel.Timeout=100 and ScSSHClient.Timeout=100 but I keep on receiving the same errors.

Any idea on the cause and how to fix it ?

Many thanks
Pio Pio

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Connection timeout expired

Post by azyk » Thu 09 Jul 2015 10:23

In the described case, SecureBridge may return the 'Connection timeout expired' error when an attempt to connect to SSH server failed. This may be due to that host/port you are using to connect to the SSH server doesn't exist or access denied.

For this same reason you may get the 'Connection could not be established' error when attempting to connect to PostgreSQL.

To solve the issue, make sure that the hosts/ports you are using in the provided code are correct and not blocked by antivirus, firewall, security policy, etc. on the VPS server.

In addition, try to set a corresponding IP address for this host/server in the TScSSHChannel.DestHost, TPgConnection.Server and TScSSHClient.HostName properties instead of the DNS name.

Post Reply