I am working on the development of a chat application using the socket.io
library in the back end and ngx-socket-io
in the front end. The chat functionality is working fine on the local environment and there is only one web socket connection in the network tab of the browser.
But when i deploy the code on the Kubernetes cluster I can see that the web socket connection does not persist longer and the previous web socket request is closed and new request is initiated i.e. the web socket connection is disconnecting and then re-connecting.
It is not persistent even on a single active pod or service in the Kubernetes cluster.
I want a single web socket connection to persist for longer duration, only then i can have the live chat working otherwise live chat ceases once a new web socket connection is initiated.
This issue was solved by using the traefik controller which is an advanced controller instead of nginx ingress controller.
You need to apply following annotations for Ingress with websocket protocol. See example here:
nginx.ingress.kubernetes.io/proxy-read-timeout: 3600
nginx.ingress.kubernetes.io/proxy-send-timeout: 3600