Search code examples
kuberneteswebsocketsocket.ionginx-ingressnetty-socketio

Socket.io connection problems inside a cluster


I'm working on an application, client-server, where I want to place them in a local Kubernetes cluster and make them communicate there via socket.io.

Then when I tried it though my application I can't seem to see the connection event on the client side although I see it on the server side once the client connects.

Here is my connection on client side:

this.socket = io("http://appteste.com/socket.io",
transports: ['polling', 'websocket'] })

Through postman I can connect to my server with the connection url:

http://appteste.com/socket.io/?EIO=3&transport=websocket

But the url generate by angular is:

http://appteste.com/socket.io/?EIO=3&transport=polling&t=P3anZPa

I tried to force the connection only via websocket, but when I did that, not even the backend connected anymore. I have already released CORS to accept requests from any origin as well.

Could anyone help me with this?

Specifications:

  • Client: Made in Angular using socket.io
  • Server: Made in SpringBoot using Netty socket.io
  • Cluster: Kubernetes initialized via kubeadm
  • Ingress: Nginx-Ingress

Any additional information you need to help, just ask!


Solution

  • When client-server is in the same DNS host, it is only necessary to set the connection like:

    this.socket = io();