admin管理员组

文章数量:1393035

I’m facing an issue where my Socket.io client fails to fully connect to a Socket.io server deployed on AKS.

  • When running Socket.io locally, the client correctly receives the 40{"sid":"<socket_id>"} message, meaning the connection is successful.
  • When connecting to the AKS-deployed server, the client only receives 40 without the sid, and the connection does not complete.
  • The issue happens over wss://, but the same client works fine when connecting to a local server.

Server: Node.js with Socket.io ([email protected])

  io.on("connection", (socket) => {
        console.log("Socket connected:", socket.id);
      });

Client: Angularapp ([email protected])

  this.socket = io(";,
      {
      transports: ["websocket"],
       path: "/nodeapp/socket.io/"
      });
      this.socket.on("connect", (socketdata:any) => {
      console.log("Connected to server");
      });

Deployment: AKS with NGINX Ingress Ingress Annotations:

ingress:
  enabled: true
  className: "nginx"
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/error-log-level: "debug"
    nginx.ingress.kubernetes.io/enable-websocket: "true"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" 
    nginx.ingress.kubernetes.io/proxy-buffering: "off"
    nginx.ingress.kubernetes.io/proxy-body-size: "100m"
  hosts:
   - host: 
     paths:
       - path: /nodeapp(/|$)(.*)
         pathType: ImplementationSpecific

Why does the Socket.io client only receive 40 (without sid) when connecting via Ingress?

Could this be an issue with Ingress proxy headers stripping the sid? Any known Azure or NGINX settings that affect WebSocket handshake completion? Would appreciate any insights or troubleshooting tips! Someone confirms a known issue with Socket.io, NGINX Ingress and suggests a fix. I has been tried with load balancer also it's also showing same error it's seems to be connection not establish correctly but socket id is generated after io.on("connection",{}).

本文标签: