iam trying to get a node JS Websocket server (socket.io) running in my Dockersetup. All of this is working in dev, but unfortunately not in my productive setup. Iam using Traefiks, which gives me these errors
{"ClientAddr":"154.28.222.54:40864","ClientHost":"154.28.222.54","ClientPort":"40864","ClientUsername":"-","DownstreamContentSize":21,"DownstreamStatus":499,"Duration":49998923447,"OriginContentSize":21,"OriginDuration":49998878062,"OriginStatus":499,"Overhead":45385,"RequestAddr":"ws.my-domain.com","RequestContentSize":0,"RequestCount":900,"RequestHost":"ws.my-domain.com","RequestMethod":"GET","RequestPath":"/","RequestPort":"-","RequestProtocol":"HTTP/2.0","RequestScheme":"https","RetryAttempts":0,"RouterName":"backend-ws@docker","ServiceAddr":"172.18.0.5:8090","ServiceName":"backend-ws@docker","ServiceURL":"http://172.18.0.5:8090","StartLocal":"2024-12-18T09:48:27.232072507Z","StartUTC":"2024-12-18T09:48:27.232072507Z","TLSCipher":"TLS_AES_128_GCM_SHA256","TLSVersion":"1.3","entryPointName":"websecure","level":"info","msg":"","time":"2024-12-18T09:49:17Z"}`{"ClientAddr":"154.28.222.120:31752","ClientHost":"154.28.222.120","ClientPort":"31752","ClientUsername":"-","DownstreamContentSize":21,"DownstreamStatus":499,"Duration":18198215524,"OriginContentSize":21,"OriginDuration":18198136123,"OriginStatus":499,"Overhead":79401,"RequestAddr":"ws.my-domain.com","RequestContentSize":0,"RequestCount":932,"RequestHost":"ws.my-domain.com","RequestMethod":"GET","RequestPath":"/","RequestPort":"-","RequestProtocol":"HTTP/2.0","RequestScheme":"https","RetryAttempts":0,"RouterName":"backend-ws@docker","ServiceAddr":"172.18.0.5:8090","ServiceName":"backend-ws@docker","ServiceURL":"http://172.18.0.5:8090","StartLocal":"2024-12-18T09:49:19.798465851Z","StartUTC":"2024-12-18T09:49:19.798465851Z","TLSCipher":"TLS_AES_128_GCM_SHA256","TLSVersion":"1.3","entryPointName":"websecure","level":"info","msg":"","time":"2024-12-18T09:49:37Z"}`{"ClientAddr":"106.75.153.133:59694","ClientHost":"106.75.153.133","ClientPort":"59694","ClientUsername":"-","DownstreamContentSize":19,"DownstreamStatus":404,"Duration":94851,"GzipRatio":0,"OriginContentSize":0,"OriginDuration":0,"OriginStatus":0,"Overhead":94851,"RequestAddr":"ws.my-domain.com","RequestContentSize":0,"RequestCount":933,"RequestHost":"ws.my-domain.com","RequestMethod":"GET","RequestPath":"/","RequestPort":"-","RequestProtocol":"HTTP/1.1","RequestScheme":"http","RetryAttempts":0,"StartLocal":"2024-12-18T09:50:04.087357753Z","StartUTC":"2024-12-18T09:50:04.087357753Z","entryPointName":"web","level":"info","msg":"","time":"2024-12-18T09:50:04Z"}`
So i do see an 499 error. My docker setup for this WS server looks like this:
services:
backend-ws:
image: node:latest
container_name: nodejs-backend-ws
command: node /usr/src/app/index.js
volumes:
- ./dist:/usr/src/app
networks:
- default
- web
labels:
- traefik.enable=true
- traefik.http.routers.backend-ws.rule=Host(`ws.my-domain.com`)
- traefik.http.routers.backend-ws.tls=true
- traefik.http.routers.backend-ws.tls.certresolver=lets-encrypt
- traefik.http.services.backend-ws.loadbalancer.server.port=8090
networks:
web:
external: true
The nodeJS WS file itself worked in prod, so i do not post it here. However my frontent service is calling this server like this:
this.socket = io("https://ws.my-domain.com:8090");
this.socket.on('connect', () => {
this.socket.emit('join', JSON.stringify(mapping), (response : any) => {
console.log(response);
})
});
Running this on chrome browser gives me:
GET https://ws.my-domain.com:8090/socket.io/?EIO=4&transport=polling&t=PFPKNzb 504 (Gateway Timeout)
I would be extremly thankful if you can give me a hint, where the problem might be. The same Dockersetup works with a regular node JS API express server without any problem. Regards, Marc
1