2 months ago
Hello, I have deployed a new applcation with websockets and I am getting an error when trying to connect to the websocket from the client. I haven't been able to find anything about it when digging, and wondering if there is some additional config or settings I need to get it to work on Railway.
I will include the error in the thread. Thanks!
0 Replies
Log 1:
web | {"level":40,"time":1744518736271,"pid":56,"hostname":"506d61f31f78","reqId":"req-8","err":{"type":"InvalidArgumentError","message":"invalid upgrade header","stack":"InvalidArgumentError: invalid upgrade header\n at processHeader (/app/node_modules/undici/lib/core/request.js:474:11)\n at new Request (/app/node_modules/undici/lib/core/request.js:192:9)\n at [http1 build request] (/app/node_modules/undici/lib/core/request.js:354:12)\n at [dispatch] (/app/node_modules/undici/lib/client.js:363:36)\n at Intercept (/app/node_modules/undici/lib/interceptor/redirectInterceptor.js:11:16)\n at [Intercepted Dispatch] (/app/node_modules/undici/lib/dispatcher-base.js:158:12)\n at Client.dispatch (/app/node_modules/undici/lib/dispatcher-base.js:179:40)\n at [dispatch] (/app/node_modules/undici/lib/pool-base.js:143:28)\n at [Intercepted Dispatch] (/app/node_modules/undici/lib/dispatcher-base.js:150:29)\n at Pool.dispatch (/app/node_modules/undici/lib/dispatcher-base.js:179:40)","name":"InvalidArgumentError","code":"UND_ERR_INVALID_ARG"},"msg":"response errored"}
Log 2:
web | {"level":50,"time":1744518736273,"pid":56,"hostname":"506d61f31f78","reqId":"req-8","req":{"method":"GET","url":"/api/ws","hostname":"medialog.ched.dev","remoteAddress":"100.64.0.4","remotePort":17600},"res":{"statusCode":500},"err":{"type":"FastifyError","message":"invalid upgrade header","stack":"FastifyError: invalid upgrade header\n at /app/node_modules/@fastify/reply-from/index.js:187:36\n at /app/node_modules/@fastify/reply-from/index.js:284:9\n at /app/node_modules/@fastify/reply-from/lib/request.js:170:9\n at RequestHandler.runInAsyncScope (node:async_hooks:206:9)\n at /app/node_modules/undici/lib/api/api-request.js:140:14\n at node:internal/process/task_queues:140:7\n at AsyncResource.runInAsyncScope (node:async_hooks:206:9)\n at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","code":"FST_REPLY_FROM_INTERNAL_SERVER_ERROR","name":"FastifyError","statusCode":500},"msg":"invalid upgrade header"}
I believe this could be because of my app setup. I am using RedwoodJS which runs an API server on one port, and a web server on another with an alias to the api server at /api
. The proxying seems to be messing up the websocket handshake.
If I add a second custom domain to point to the API server port, I can connect to that domain with the websocket URL as expected.
Sorry for the alarm, but I will keep this here in case anyone else is in a similar situation.
2 months ago
!s
Status changed to Solved brody • about 2 months ago