socket io connected without on connection event on server side (GKE)

209 Views Asked by At

I deployed a Socket.io based app in GKE. I already use Redis adapter to handle multiple pods. Cookie affinity already set in Ingress setting.

I use dynamic namespace. I ONLY USE 1 POD on GKE. When I scaled from 1 pod to 0 pod, then to 1 pod again, did it repeatedly, sometimes socket.io works, sometimes its does not works. When it does not works, here is the VERY STRANGE behavior I observed:

  • On connection event on server side not fired, event though the socket already connected. I know socket already connected because I printed all of them.

I doubted Redis adapter? Anyone has seen this before?

Thanks!

1

There are 1 best solutions below

0
On

Posting this answer as a community wiki to highlight the fact that the issue was resolved.

Feel free to edit and expand.


As posted in the comments:

Thanks, I found the issue. Its because of the dynamic namespace. The problem is, when you use io.of(nsp), if the nsp is not created yet, it will be created with the undefine on the connect handler. Therefore, our dynamic namespace on connect handler was not set.


Additional resources: