Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get pgmockproxy to start #2

Closed
andheiberg opened this issue May 14, 2021 · 3 comments
Closed

Can't get pgmockproxy to start #2

andheiberg opened this issue May 14, 2021 · 3 comments

Comments

@andheiberg
Copy link

Setup:

Get a postgres server running:

$ docker run -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres

Run the proxy:

./pgproxy -listen 127.0.0.1:5433 -remote 127.0.0.1:5432

Connect to the proxy. (work around issue with SSL jackc/pgproto3#15):

psql "sslmode=disable host=localhost port=5433 user=postgres"

Result:

$ ./pgproxy -listen 127.0.0.1:5433 -remote 127.0.0.1:5432
F {"Type":"StartupMessage","ProtocolVersion":196608,"Parameters":{"application_name":"psql","client_encoding":"UTF8","database":"postgres","user":"postgres"}}
B {"Salt":[12,118,255,169]}
2021/05/14 16:21:52 EOF

This differs dramatically from what can be seen in the readme. So far I've yet to find an obvious explanation for what is going on :(

@henvic
Copy link

henvic commented May 16, 2021

Hey @andheiberg, what is the code you're using to connect to the database?

I think what might be happening is that you're closing the connection. When this happens, the proxy exits indeed.

@andheiberg
Copy link
Author

andheiberg commented May 16, 2021

@henvic there is no code used for connecting to the database. I used the psql CLI tool as shown above.

The proxy closes before psql even asks me to type the password.

@andheiberg
Copy link
Author

Interestingly by adding some code (as per the suggestion in jackc/pgproto3#15) that denies the SSL request I got psql -h 127.0.0.1 -p 5433 -U postgres -W to work.

When I use this method of configuring psql everything works 👍

❯ ./pgproxy -listen 127.0.0.1:5433 -remote 127.0.0.1:5432
F {"Type":"SSLRequest","ProtocolVersion":0,"Parameters":null}
B N
F {"Type":"StartupMessage","ProtocolVersion":196608,"Parameters":{"application_name":"psql","client_encoding":"UTF8","database":"postgres","user":"postgres"}}
B {"Salt":[184,162,98,158]}
F {"Type":"PasswordMessage","Password":"md56f7d4982168003ce1e58771959a7ab53"}
B {}
B {"Type":"ParameterStatus","Name":"application_name","Value":"psql"}
B {"Type":"ParameterStatus","Name":"client_encoding","Value":"UTF8"}
B {"Type":"ParameterStatus","Name":"DateStyle","Value":"ISO, MDY"}
B {"Type":"ParameterStatus","Name":"integer_datetimes","Value":"on"}
B {"Type":"ParameterStatus","Name":"IntervalStyle","Value":"postgres"}
B {"Type":"ParameterStatus","Name":"is_superuser","Value":"on"}
B {"Type":"ParameterStatus","Name":"server_encoding","Value":"UTF8"}
B {"Type":"ParameterStatus","Name":"server_version","Value":"13.2 (Debian 13.2-1.pgdg100+1)"}
B {"Type":"ParameterStatus","Name":"session_authorization","Value":"postgres"}
B {"Type":"ParameterStatus","Name":"standard_conforming_strings","Value":"on"}
B {"Type":"ParameterStatus","Name":"TimeZone","Value":"Etc/UTC"}
B {"Type":"BackendKeyData","ProcessID":2211,"SecretKey":394727031}
B {"Type":"ReadyForQuery","TxStatus":"I"}
F {"Type":"Query","String":"SELECT VERSION();"}
B {"Type":"RowDescription","Fields":[{"Name":"version","TableOID":0,"TableAttributeNumber":0,"DataTypeOID":25,"DataTypeSize":-1,"TypeModifier":-1,"Format":0}]}
B {"Type":"DataRow","Values":[{"text":"PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit"}]}
B {"Type":"CommandComplete","CommandTag":"SELECT 1"}
B {"Type":"ReadyForQuery","TxStatus":"I"}
F {"Type":"Terminate"}

The issue persists when using psql "sslmode=disable host=localhost port=5433 user=postgres". I'm not sure there is much value in my tracking down why though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants