Closed kevinwolfcr closed 1 year ago
Hello @kevinwolfcr!
I tried to reproduce your issue with the code from the tutorial and didn't have the issues with wsproxy. Here's my wsproxy output:
tmpdc-db-proxy-1 | 2023/06/26 19:00:24 Got request from 172.20.0.1:34270
tmpdc-db-proxy-1 | 2023/06/26 19:00:24 Got request from 172.20.0.1:34270, proxying to db:5432, allowed=true, addressArg=, hostHeader=localhost:5433
tmpdc-db-proxy-1 | 2023/06/26 19:00:24 Got 58 bytes client->pg: AAAAOgADAAB1c2VyAG15X3VzZXIAZGF0YWJhc2UAbXlfZGIAY2xpZW50X2VuY29kaW5nAFVURjgAAA==
tmpdc-db-proxy-1 | 2023/06/26 19:00:24 Got 24 bytes pg->client: UgAAABcAAAAKU0NSQU0tU0hBLTI1NgAA
Client code was taken from the tutorial:
// if we're running locally
if (!process.env.VERCEL_ENV) {
// Set the WebSocket proxy to work with the local instance
neonConfig.wsProxy = (host) => `${host}:5433/v1`;
// Disable all authentication and encryption
neonConfig.useSecureWebSocket = false;
neonConfig.pipelineTLS = false;
neonConfig.pipelineConnect = false;
console.log(neonConfig);
}
if (!process.env.POSTGRES_URL) {
throw new Error("POSTGRES_URL is not set");
}
export const db = new Kysely<Database>({
dialect: new NeonDialect({
connectionString: process.env.POSTGRES_URL,
}),
});
POSTGRES_URL
here is postgres://my_user:my_password@localhost:5432/my_db
.
By looking at your output, I can guess that you have a different neonConfig.wsProxy
function, you can try to copy it from my snippet and it should work for you.
Or, if you just remove APPEND_PORT
from docker-compose.yml
file, it will not spoil the address and should work as well.
Hello @petuhovskiy, thanks for your answer. You are right, indeed the issue was that I wasn't defining a wsProxy
function and instead, passing a string directly (neonConfig.wsProxy =
localhost:5433/v`), switching to function mode worked.
Thanks!
Steps to reproduce
Following this tutorial, I created this file:
docker-compose.yml
Expected result
My request is proxied successfully.
Actual result
The request is not proxied, since the
APPEND_PORT
is just concatenating to theaddr
in the script. So it is trying to proxy tolocalhost:5432db:5432
rather thandb:5432
Environment
Local development using
docker-compose
in an Apple M1 Pro computer (not sure if this is the issue, since I have experienced issues with docker on this architecture before).Logs, links
docker logs