HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Struggling with pgBouncer

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
withpgbouncerstruggling

Problem

I've got Postgres 9.2 and PgBouncer (The version that came with the 'stack builder'). I have a .net application connecting via Npgsql version 2.0.12 on a win7 machine.

My application can happily connect straight to the postgres server, but always fails to connect via the pgbouncer.

My connection string to npgsql (after some substitution is)

Sslmode=Prefer;Timeout=40;Server={0};Port={3};User Id={4};Password={1};Database={2};Pooling=False;


(I've also tried to connect to PgBounce with Protocol=3 explicitly and that didn't work.)

The database line from pgBounce ini is:

[databases]
something = host=localhost port=5433 dbname=somethingelse user=someone password=aaa


and in the userlist.txt I have "someone" "aaa" as required.

When my app runs the npgsql says "connection forcibly closed" and the pgbouncer error log says:

2013-02-06 20:16:57.594 2444 LOG File descriptor limit: -1 (H:-1), max_client_conn: 1000, max fds possible: 1030
2013-02-06 20:16:57.649 2444 LOG listening on ::/6433
2013-02-06 20:16:57.657 2444 LOG listening on 0.0.0.0:6433
2013-02-06 20:16:57.659 2444 LOG process up: pgbouncer 1.5.2, libevent 2.0.19-stable (win32), adns: evdns2
2013-02-06 20:17:22.066 2444 LOG C-01819410: something/someone@fe80::997b:396e:eacc:dd2b:3013 login attempt: db=somethingelse user=someone
2013-02-06 20:17:22.130 2444 LOG S-01836648: something/someone@127.0.0.1:5433 new connection to server
2013-02-06 20:17:24.069 2444 LOG C-01819410: something/someone@fe80::997b:396e:eacc:dd2b:3013 closing because: client close request (age=2)
2013-02-06 20:17:26.319 2444 LOG C-01819410: (nodb)/(nouser)@fe80::997b:396e:eacc:dd2b:3023 closing because: bad packet header (age=0)
2013-02-06 20:17:26.322 2444 WARNING C-01819410: (nodb)/(nouser)@fe80::997b:396e:eacc:dd2b:3023 Pooler Error: bad packet header


The npgsql exception says: (from a log file in app, the topmost exception follows down the nested exceptions):

```
Exception message: Unable to read data from the

Solution

The userlist.txt file contains the accounts for connecting from your client to PgBouncer. The [databases] section contains the login information for connection from PgBouncer to the backend PostgreSQL server. You appear to be mixing these two up.

When you connect from your client to PgBouncer you need to provide a user name and password from userlist.txt and a database name of something in this case.

Context

StackExchange Database Administrators Q#34136, answer score: 9

Revisions (0)

No revisions yet.