<p>I am working on the development of a chat application using the <code>socket.io</code> library in the back end and <code>ngx-socket-io</code> 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. </p>

<p>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.</p>

<p>It is not persistent even on a single active pod or service in the Kubernetes cluster.</p>

<p>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.
<a href="https://i.stack.imgur.com/b4frm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b4frm.jpg" alt="enter image description here"></a></p>

Deepika Sharma
<p>You need to apply following annotations for Ingress with websocket protocol. See example <a href="https://github.com/kubernetes/ingress-nginx/issues/3746" rel="nofollow noreferrer">here</a>:</p>

<pre><code>nginx.ingress.kubernetes.io/proxy-read-timeout: 3600
nginx.ingress.kubernetes.io/proxy-send-timeout: 3600
</code></pre>
