I want to show some pgbouncer stats in a simple wpf client (npgsql), but I can't connect to pgbouncer. The connect to a postgresql database via pgbouncer is working well, but the connect to pgbouncer admin database is not. With the used credentials I don't have any problems to connect with psql.
The Code:
var connString = "Server=X.X.X.X;Port=6432;User Id=pgbouncer;Password=myPw;Database=pgbouncer;";
using (var con = new NpgsqlConnection(connString))
{
await con.OpenAsync();
return (await new NpgsqlCommand(sql, con).ExecuteScalarAsync()).ToString();
}
I get the error 08P01: unsupported pkt type: 80 on opening the connection.
In this post the problem could be solved by an extra parameter in the jdbc connectionstring, but this parameter seems unavailable in a npgsql connectionstring.
How can I get some pgbouncer stats in a c# client?
EDIT:
In the meantime I tried Devart provider (Express edition), but it don't work too, because the provider commits a SELECT VERSION(); during the connect, and the pgbouncer database don't understand this statement => Exception. In pgbouncer forum I can't find a solution as well.
I can't believe that this task apparently is so rarely. I'm really surprised.
PostgreSQL has two query protocols at the wire level - the simple protocol and the extended protocol; it seems that the pgbouncer admin interface supports only the simple protocol, but Npgsql only supports the extended protocol. That unfortunately means that the two are incompatible at the moment.
This issue tracks adding support for the simple protocol to Npgsql.
Related
I've been trying to deploy a discord bot on heroku for days, I use a postgresql database hosted on aws with heroku postgres. I've had many problems trying to connect with ssl to the database using asyncpg, I could find the solutions to some of the problems on the internet but I am now stuck with this error :
2020-12-28T10:33:11.856268+00:00 app[worker.1]: raise exceptions.InterfaceError(
2020-12-28T10:33:11.856403+00:00 app[worker.1]: asyncpg.exceptions._base.InterfaceError: `ssl` parameter can only be enabled for TCP addresses, got a UNIX socket path: '/run/postgresql/.s.PGSQL.5432'
This is how I connect to the database :
ctx = ssl.create_default_context(cafile='rds-ca-2019-eu-west-1.pem')
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
bot.con = await asyncpg.create_pool(dsn=DATABASE_URI, ssl=ctx)
...
bot.loop.run_until_complete(create_db_pool())
I have no clue of why I have that error, when trying to deploy my code on Heroku. I don't have that problem running it from my computer..
Tried to read the asyncpg documentation, not much came out of it. I don't know why it's using unix sockets and didn't really understand how it works, but I've read that asyncpg is supposed to support ssl connexion now...
Do you think there is a way to make this work, or should I just switch to psycopg2 ?
Question:
- Need to connect to Postgresql using Npgsql using multiple connection string?
- How does npgsql connect to Postresql? does it use JDBC dirvers?
Reason: Need for multiple connection string
- For handling failover scenario where Primary DB server goes down and secondary / standby server become primary
Current libraries:
- Npgsql(3.2.5)
- Npgsql.EntityFrameworkCore.PostgreSQL (2.0.0)
- Npgsql.EntityFrameworkCore.PostgreSQL.Design (1.1.1)
Looking forward for alternate approach
Specifying multiple hosts in the connection string isn't currently supported. It is tracked in this issue, and there's a high probability we'll do it for the next version. For now you'll have to implement it yourself, by catching connection exceptions from the first attempt and manually trying to connect to the second server.
Other than that, Npgsql is a pure .NET driver that has nothing to do with JDBC.
I have a pgpool 3.5.4 with memcache enabled, and I use it to connect to
Redshift.
I wrote two simple programs, one in Java (JDBC
postgresql-9.4.1212.jre6.jar) and another one in Python (using psycopg2
postgres package) that just connects to pgpool, and execute a simple query
(eg: select * from customer limit 10;) and I've noticed strange and
different behaviors. I also ran the queries using the command line tool
psql.
1) Using JDBC with pgpool with caching enabled I get an error
2016-11-15 10:56:27: pid 31043: FATAL: Backend throw an error message
2016-11-15 10:56:27: pid 31043: DETAIL: Exiting current session because of
an error from backend
2016-11-15 10:56:27: pid 31043: HINT: BACKEND Error: "portal "pgpool31043"
does not exist"
2) Using JDBC with pgpool with caching disabled it works
3) Using psycopg2 or psql command line with pgpool with caching either
enabled or disabled it works
Can someone help me understand why only JDBC is not working?
There are two protocols JDBC uses to communicate, simple query protocol and extended query protocol.
pgpool II however, doesn't work very well with extended query protocol.
In the documentation of pgjdbc driver in github (https://github.com/pgjdbc/pgjdbc) there is a parameter named preferQueryMode. To fix this issue, just set the preferQueryMode to simple, and the problem will just go away.
I tested this set up with two customers so far, using pgpool in front of postgres and redshift, and it worked perfectly.
I've just uploaded my locally developed app to CloudBees. It works fine: I can load the web pages and it can access the database.
However, I cannot connect to its database (also provided by CloudBees) using MySQL Workbench or the command line tool. It always says
Can't connect to MySQL server on 'ec2-50-19-213-178.compute-1.amazonaws.com' (10060)
Any CloudBees configuration that I might be missing?
double check your database connection parameters using SDK : bees db:info -p <databasename>
you should be able to connect to DB using mysql workbench and other mysql tools.
In the MySQL forum exists a collection of links for various types of connections using MySQL Workbench. One is probably especially interesting for you as it deals with Amazon RDS databases. Among others it shows what connection parameters are needed.
Seems that there were some firewall problems in the corporate router that prevented me from connecting before. I tried at home and it worked.
I'm getting this error when i try to connect to DB2 Database server using OLEDBConnection in Visual studio 2008 windows application developed in c#:
SQL30082N Attempt to establish connection failed with security reason 5
I'm using Microsoft OLEDB Provider for DB2. When i try to connect i am getting the above error.
I am using the below connection string for connecting to DB2
ConnectionStr = "Provider=IBMDADB2;Database="SampDB";Hostname=114.968.25.61;Protocol=TCPIP;Port=60001;Uid =testuser; Pwd=!DB2User!;";
I am 100% sure that this userid is correct. My DB2 client provider version is 8.0
In my desktop i am getting this error. but this windows application works well on all others machine. Please help me in fixing the issue.
According to Info Center, reason code 5 for SQLSTATE SQL30082N means that the UserId is missing.
I think what may be the issue (if you copied and pasted your exact connection string) is that there is an extra space after Uid.
If you're using .NET, then you may want to look at the OleDbConnectionString class. It will format and escape the connection string as needed.