N
Neon2y ago
metropolitan-bronze

Barebones .NET Project Can't Connect - Console Request Failed

Hey folks. I've got an extremely simple console app and a free-tier database.
using Npgsql;

var builder = new NpgsqlConnectionStringBuilder();
builder.Host = "";
builder.Database = "";
builder.Username = "";
builder.Password = "";

var cn = new NpgsqlConnection(builder.ConnectionString);
cn.Open();
using Npgsql;

var builder = new NpgsqlConnectionStringBuilder();
builder.Host = "";
builder.Database = "";
builder.Username = "";
builder.Password = "";

var cn = new NpgsqlConnection(builder.ConnectionString);
cn.Open();
Ngpsql is the leading .NET Postgres database provider. With this setup I am routinely getting an error message Console Request Failed (attached). I'm...not sure how much help I can get here because I can connect to the database from my IDE itself. But this driver is the de-facto option in .NET, so it feels like something weird is happening here. Any advice? Thank you.
No description
8 Replies
metropolitan-bronze
metropolitan-bronzeOP2y ago
Worth nothing that making any parameter incorrect throws a different error (host not found, invalid auth), and that I can connect to a quickly-spun-up postgres docker image.
unwilling-turquoise
unwilling-turquoise2y ago
Can you try and log the connection string that is created by the builder and share that here (with the password redacted)?
metropolitan-bronze
metropolitan-bronzeOP2y ago
Host=ep-gentle-**-**.us-east-2.aws.neon.tech;Database=p******;Username=sha**9+neon;Password=******k
unwilling-turquoise
unwilling-turquoise2y ago
Hmm, interesting Looks like the + in your username is causing some issues, you can try create a new role in the console and I'll file a bug report
metropolitan-bronze
metropolitan-bronzeOP2y ago
Just for reference this is a trick that I and many others do with email providers that lets you identify email addresses that you hand out to a specific business. For instance, if I sign up with email+neon@gmail.com and then I get a spam email from pornprovider.com directed to email+neon@gmail.com, I know who sold my stuff :Kek: Looks like that worked with a new role! Thank you very much (:
unwilling-turquoise
unwilling-turquoise2y ago
Yeah I'm aware of the trick 😉 in this case your postgres user and your email don't have to match, but we create the default user based on your email
metropolitan-bronze
metropolitan-bronzeOP2y ago
tysm. mostly clarified so you don't think I'm a crazy user doing whacky edge-case shit. have a good weekend! :pocky_d_keeto_vibe:
wise-white
wise-white2y ago
Nice find. Thanks for tracking/logging this @Conrad Ludgate

Did you find this page helpful?