Frequent Disconnection and re-connection of web socket requests after deployment in the K8s

4/8/2020

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. enter image description here

-- Deepika Sharma
angularjs
kubernetes
node.js
socket.io
websocket

2 Answers

4/20/2020

This issue was solved by using the traefik controller which is an advanced controller instead of nginx ingress controller.

-- Deepika Sharma
Source: StackOverflow

4/8/2020

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
-- Anton Matsiuk
Source: StackOverflow