N
Neon2y ago
helpful-purple

Local development and CI

For local development and CI how do you connect with websockets? Here is my docker-compose.yaml
version: "3.4"
services:
postgres:
image: postgres
environment:
POSTGRES_DB: testdb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 5432:5432
volumes:
- "${PWD}/dev-data/postgres:/var/lib/postgresql/data"
pg_proxy:
image: ghcr.io/neondatabase/wsproxy:latest
environment:
APPEND_PORT: "postgres:5432"
ALLOW_ADDR_REGEX: ".*"
LOG_TRAFFIC: "true"
ports:
- 5433:80
- 2112:2112
depends_on:
- postgres
version: "3.4"
services:
postgres:
image: postgres
environment:
POSTGRES_DB: testdb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 5432:5432
volumes:
- "${PWD}/dev-data/postgres:/var/lib/postgresql/data"
pg_proxy:
image: ghcr.io/neondatabase/wsproxy:latest
environment:
APPEND_PORT: "postgres:5432"
ALLOW_ADDR_REGEX: ".*"
LOG_TRAFFIC: "true"
ports:
- 5433:80
- 2112:2112
depends_on:
- postgres
and here is my drizzle orm connection logic
import { Pool } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-serverless";


const pool = new Pool({ connectionString: process.env.DATABASE_URL });

export const db = drizzle(pool);
import { Pool } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-serverless";


const pool = new Pool({ connectionString: process.env.DATABASE_URL });

export const db = drizzle(pool);
I'm unable to connect and I get the following error: Error: All attempts to open a WebSocket to connect to the database failed. Please refer to https://github.com/neondatabase/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websocket--undefined. Details: fetch failed
2 Replies
other-emerald
other-emerald2y ago
You need to opt-in/configure the proxy during local development. Usually that involves checking an environment variable. Example: https://github.com/evanshortiss/neon-docker-wss-proxy-local/blob/main/index.ts
GitHub
neon-docker-wss-proxy-local/index.ts at main · evanshortiss/neon-do...
Contribute to evanshortiss/neon-docker-wss-proxy-local development by creating an account on GitHub.
helpful-purple
helpful-purpleOP2y ago
Oh i missed that, thanks

Did you find this page helpful?