Page 1 of 3

exception UniError

Posted: Sun 02 Jun 2013 11:48
by Suhaimin
Hello ,


I have a comp B IP address 192.168.1.1 installed Postgres 9.1 then i run a application everything is ok.
uniconnection.close;
uniconnection.server :='';
uniconnection.connect;



then i copy that application to computer B (IP address 192.168.1.2 ) without install postgres
uniconnection.close;
uniconnection.server :='192.168.1.1';
uniconnection.connect;

after i run this application error occurs... why this happened ? thank a lot

Re: exception UniError

Posted: Sun 02 Jun 2013 12:27
by Suhaimin
Hello,

i forgot the error code occur :
EXCEPTION UNIERROR

CANNOT CONNECT TO SERVER ON HOST 'LOCALHOST'
NO CONNEC1TION COULD BE MADE BECAUSE THE TARGET MACHINE
ACTIVELY FEFUSED IT
SOCKET ERROR CODE 10061


thanks in advance

Re: exception UniError

Posted: Mon 03 Jun 2013 08:55
by lao
Hi,
i think you need to modify you pg_hba.conf and add authorized computers ip.
regards

Re: exception UniError

Posted: Mon 03 Jun 2013 09:14
by DemetrionQ
Hello.

This error occurs in case when you set 'localhost' or '' in the TUniConnection.Server property and run your application on a PC, where the DB server is not installed. Please make sure that you have really specified the ip-address of the remote server in the TUniConnection.Server property.
If this information doesn't help solve the problem, please specify your UniDAC version.

Re: exception UniError

Posted: Mon 03 Jun 2013 11:38
by Suhaimin
Hi

Delphi 7 Unidac 4.6.11 Profesional Edition.
I have a comp A IP address 192.168.1.1 installed Postgres 9.1 then after application run everything is ok.
uniconnection.close;
uniconnection.server :='';
uniconnection.port :=0;
uniconnection.connect;



then i copy that application to computer B (IP address 192.168.1.2 ) without install postgres..
uniconnection.close;
uniconnection.server :='192.168.1.1';
uniconnection.connect;

after i run this application error occurs.


EXCEPTION UNIERROR

Cannot Connect to server on hOst "localhost',
no connection could be made because the target machine
ACTIVELY FEFUSED IT
SOCKET ERROR CODE 10061



then i change my code to
uniconnection.close;
uniconnection.port :=5432;
uniconnection.server :='192.168.1.1';
uniconnection.connect;


error occurs :
Unknown host : 192.168.1.1

should I install postgresql 9.1 in comp B OR used libpg.dll ?
please advise.. thanks a lot

Re: exception UniError

Posted: Mon 03 Jun 2013 11:59
by Suhaimin
Hello,

should I need to modify pg_hba.conf as Lao said ? please advise.. thanks a lot

Re: exception UniError

Posted: Mon 03 Jun 2013 14:20
by DemetrionQ
PgDAC connect to a server directly without using libpg.dll or other PostgreSQL libraries. To connect to a remote server, you don't need to install PostgreSQL server on a client PC.
To connect to a PostgreSQL server, it should be enabled and set correctly. In addition, firewalls of the client and server computers should be set correctly, so that not to block client-server connection.

pg_hba.conf is a PostgreSQL server configuration file responsible for client authentication. By default, this config file contains settings, that allow connection to a server from a local PC only. If you need to open access to other computers, you should modify the pg_hba.conf file in an appropriate way. For example, in your case, you should add the following string:

Code: Select all

host all all 192.168.1.2/32 trust
In addition, you should modify the postgresql.conf file by adding or editing the following string:

Code: Select all

listen_addresses = '*'
This will allow the server listen all IP-addresses of incoming connections.

The detail information about PostgreSQL server configuration can be found in the PostgreSQL server documentation, for example, here:
http://www.postgresql.org/docs/9.1/stat ... -conf.html
http://www.postgresql.org/docs/9.1/stat ... ction.html

Re: exception UniError

Posted: Mon 03 Jun 2013 14:59
by Suhaimin
Hello,


Should I also set port to 5432 at client computer ? thanks for you help... thanks a lot

Re: exception UniError

Posted: Tue 04 Jun 2013 11:23
by Suhaimin
Hello,


I follow your instructions, but after I run the application in client computer still error occur :

"no pg_hba.conf entry for host 192.168.1.2 , user postgres database pos sll off "

how to handle this error? thanks a lot

Re: exception UniError

Posted: Tue 04 Jun 2013 13:56
by DemetrionQ
Hello.

Please make sure you have really added the following string to the pg_hba.conf file:

Code: Select all

host all all 192.168.1.2/32 trust
In order for the changes made in pg_hba.conf to be applied, you should restart the PostgreSQL server.

Re: exception UniError

Posted: Wed 05 Jun 2013 11:11
by Suhaimin
Hello


Computer A : windows XP
I have already added following string to the pg_hba.conf file:

# TYPE DATABASE USER ADDRESS METHOD

@remove-line-for-nolocal@# "local" is for Unix domain socket connections only
@remove-line-for-nolocal@local all all @authmethodlocal@
# IPv4 local connections:
host all all 127.0.0.1/32 @authmethod@
host all all 192.168.1.2/32 trust
# IPv6 local connections:
host all all ::1/128 @authmethod@
# Allow replication connections from localhost, by a user with the
# replication privilege.
@remove-line-for-nolocal@#local replication @default_username@ @authmethodlocal@
#host replication @default_username@ 127.0.0.1/32 @authmethod@
#host replication @default_username@ ::1/128 @authmethod@


and I have already added postgresql.conf.sample file to :

# - Connection Settings -

#listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
# (change requires restart)
#port = 5432 # (change requires restart)
#max_connections = 100 # (change requires restart)
# Note: Increasing max_connections costs ~400 bytes of shared memory per
# connection slot, plus lock space (see max_locks_per_transaction).
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directory = '' # (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour = off # advertise server via Bonjour
# (change requires restart)
#bonjour_name = '' # defaults to the computer name
# (change requires restart)
And already restart windows XP ;



Computer B : windows XP
I run the application but still error occurs :
"no pg_hba.conf entry for host 192.168.1.2 , user postgres database TEST sll off "

why this error occurs ? thanks a lot

Re: exception UniError

Posted: Wed 05 Jun 2013 13:51
by Suhaimin
Hello,

Firewall at computer A disable, but computer client still can not connect to server A..
I have followed your clues but still error occurs.. please advices...thanks a lot

Re: exception UniError

Posted: Wed 05 Jun 2013 13:57
by Suhaimin
Hello,


# TYPE DATABASE USER ADDRESS METHOD
@remove-line-for-nolocal@# "local" is for Unix domain socket connections only
@remove-line-for-nolocal@local all all @authmethodlocal@
# IPv4 local connections:
host all all 127.0.0.1/32 @authmethod@
host all all 192.168.1.2 trust
# IPv6 local connections:
host all all ::1/128 @authmethod@

----- which ones is correct setting----
#host all all 192.168.1.2 trust
host all all 192.168.1.2 trust ????

correct setting with prefix "#" or NOT ? OR do i need added "@trust@" ??


please advise... thanks a lot

Re: exception UniError

Posted: Wed 05 Jun 2013 14:23
by FCS
Hello,

Try connect to this database using other tools (http://www.dtsql.com).

Check firewall options.
Check network connection (cables, ping, share some folder on A computer and browse it from B computer).
Try connect from other computer, maybe the computer B has same problems.
Uninstall antivirus software on both computers.

Regards
Michal

Re: exception UniError

Posted: Wed 05 Jun 2013 14:57
by Suhaimin
Hello,

I have tried ping from comp B to A everything ok... firewall is disable too and already tried with other computer the samething happened... any suggestion please...thanks a lot..