<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi,<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I kindly need your help and expertise on a strange situation we&#8217;re facing when using PGPool II.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>Our setup is 2 Centos 5.3 servers with installed Postgres 9.1 (on port 5432) and PGPool II 3.2.0.0 (on port 9999).<o:p></o:p></p><p class=MsoNormal>What we want to do, is to establish replication between the 2 servers, with one to serve as the main server and the other as the standby.<o:p></o:p></p><p class=MsoNormal>To achieve that, we followed the instructions in this tutorial:<o:p></o:p></p><p class=MsoNormal><a href="http://pgpool.projects.postgresql.org/pgpool-II/doc/tutorial-en.html">http://pgpool.projects.postgresql.org/pgpool-II/doc/tutorial-en.html</a><o:p></o:p></p><p class=MsoNormal>and we managed to successfully establish replication.<o:p></o:p></p><p class=MsoNormal>When we run (as postgres)<o:p></o:p></p><p class=MsoNormal>&nbsp; createddb &#8211;p 9999 dbname <o:p></o:p></p><p class=MsoNormal>on the main server then we can see the changes on the standby server.<o:p></o:p></p><p class=MsoNormal>So far, so good.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>The problem we&#8217;ve got is when Java come into play. <o:p></o:p></p><p class=MsoNormal>For some reason Java applications are not able establish a connection to PGPool but are able to do it to the Postgres server.<o:p></o:p></p><p class=MsoNormal>For example, connecting to jdbc:postgresql://localhost:9999/dbname&nbsp; and running SELECT VERSION() throws an error.<o:p></o:p></p><p class=MsoNormal>But, if we connect to jdbc:postgresql://localhost:5432/dbname we get back some results.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>The error in Postgres log is:<o:p></o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:"Courier New"'>LOG:&nbsp; unexpected EOF on client connection<o:p></o:p></span></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>This is strange, as createdb &nbsp;-p 9999 connects to PGPool with no problem.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>So, we set loglevel=2 to the jdbc url in order to get some more advanced network messages and we got:<o:p></o:p></p><p class=MsoNormal>PostgreSQL 9.1 JDBC4 (build 901)<o:p></o:p></p><p class=MsoNormal>Trying to establish a protocol version 3 connection to localhost:9999<o:p></o:p></p><p class=MsoNormal>FE=&gt; StartupPacket(user=postgres, database=dbname, client_encoding=UTF8, DateStyle=ISO, extra_float_digits=2)<o:p></o:p></p><p class=MsoNormal>&lt;=BE AuthenticationOk<o:p></o:p></p><p class=MsoNormal>org.postgresql.util.PSQLException: The connection attempt failed.<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:152)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.postgresql.jdbc2.AbstractJdbc2Connection.&lt;init&gt;(AbstractJdbc2Connection.java:125)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.postgresql.jdbc3.AbstractJdbc3Connection.&lt;init&gt;(AbstractJdbc3Connection.java:30)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.postgresql.jdbc3g.AbstractJdbc3gConnection.&lt;init&gt;(AbstractJdbc3gConnection.java:22)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.postgresql.jdbc4.AbstractJdbc4Connection.&lt;init&gt;(AbstractJdbc4Connection.java:32)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.postgresql.jdbc4.Jdbc4Connection.&lt;init&gt;(Jdbc4Connection.java:24)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.postgresql.Driver.makeConnection(Driver.java:393)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.postgresql.Driver.connect(Driver.java:267)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.sql.DriverManager.getConnection(DriverManager.java:582)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.sql.DriverManager.getConnection(DriverManager.java:185)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at replication.Main.printVersion(Main.java:41)<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at replication.Main.main(Main.java:23)<o:p></o:p></p><p class=MsoNormal>SQLException: SQLState(08001)<o:p></o:p></p><p class=MsoNormal>getConnection failed: org.postgresql.util.PSQLException: The connection attempt failed.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>We looked for SQLState (08001) and for Postgres it means that &#8216;sql client unable to establish connection&#8217;.<o:p></o:p></p><p class=MsoNormal>And this is where we ran out of ideas.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>So, to summarize, we&#8217;re in a situation where replication has been established successfully on port 9999.<o:p></o:p></p><p class=MsoNormal>Java (jdbc) can connect with success to Postgres (5432) but not to PGPool (9999), as the connection gets terminated for some reason right after AuthenticationOK is sent to the client.<o:p></o:p></p><p class=MsoNormal>(I don&#8217;t know if that is important to mention but we have opened ports 5432, 9999 and 9898 for tcp connections on both server firewalls)<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>Do you have any ideas what is causing this problem?<o:p></o:p></p><p class=MsoNormal>Any help and directions will be much appreciated.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>Kind regards,<o:p></o:p></p><p class=MsoNormal>Stelios<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></body></html>