最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

kubernetes - Socket.io Client Not Connecting to AKS-Deployed Socket.io Server (Only Receiving 40 Without sid) - Stack Overflow

programmeradmin1浏览0评论

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",{}).

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论