admin管理员组文章数量:1430997
I am currently setting up a local development environment for a Next.js application. Following the instructions at , I have configured Docker containers for Postgres and WSProxy locally. I am attempting to connect to these services from the app running with npm run dev. However, I am encountering the following error:
Error fetching recipes: ErrorEvent {
[Symbol(kTarget)]: WebSocket {
_events: [Object: null prototype] {
error: [Function],
message: [Function],
close: [Function],
open: [Function]
},
_eventsCount: 4,
_maxListeners: undefined,
_binaryType: 'arraybuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: <Buffer >,
_closeTimer: null,
_extensions: {},
_paused: false,
_protocol: '',
_readyState: 3,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_autoPong: true,
_url: 'wss://localhost/v2',
_req: null,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
[Symbol(kType)]: 'error',
[Symbol(kError)]: AggregateError [ECONNREFUSED]:
at internalConnectMultiple (node:net:1117:18)
at afterConnectMultiple (node:net:1684:7)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'ECONNREFUSED',
[errors]: [ [Error], [Error] ]
},
[Symbol(kMessage)]: ''
}
There are no logs displayed in the Postgres and WSProxy containers, indicating that the requests are not reaching them.
In the API route file, I checked the neonConfig settings as follows, and it appears that the settings from db.ts are being applied correctly:
export async function GET() {
try {
console.log('neonConfig settings:', {
wsProxy: neonConfig.wsProxy,
useSecureWebSocket: neonConfig.useSecureWebSocket,
pipelineTLS: neonConfig.pipelineTLS,
pipelineConnect: neonConfig.pipelineConnect,
});
console.log(neonConfig.wsProxy?.toString());
const result = await sql.query(`SELECT id, ...`);
...
However, the error log shows _url: 'wss://localhost/v2'. Additionally, the documentation at .md?plain=1#L266 states the following:
#### `wsProxy: string | (host: string, port: number | string) => string`
If connecting to a non-Neon database, the `wsProxy` option should point to [your WebSocket proxy](DEPLOY.md). It can either be a string, which will have `?address=host:port` appended to it, or a function with the signature `(host: string, port: number | string) => string`. Either way, the protocol must _not_ be included, because this depends on other options. For example, when using the `wsproxy` proxy, the `wsProxy` option should look something like this:
Default: `host => host + '/v2'`.
Therefore, it seems that the wsProxy: neonConfig.wsProxy setting is not being applied correctly. Could you please provide guidance on how to resolve this issue?
Thank you for your assistance.
Best regards,
本文标签: postgresqlIssue with WebSocket Proxy Configuration for Local Development in Nextjs AppStack Overflow
版权声明:本文标题:postgresql - Issue with WebSocket Proxy Configuration for Local Development in Next.js App - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745557397a2663267.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论