<p>I tried to proxy websocket using ingress HTTP(s) load balancer in google cloud container engine. Connection establishment and data reading properly. But connection timeout after 30 s. Google documentation (<a href="https://cloud.google.com/compute/docs/load-balancing/http/" rel="noreferrer">https://cloud.google.com/compute/docs/load-balancing/http/</a>) says to change <strong>timeout value (timeoutSec in the API)</strong> </p>

<p>But cannot found a proper way to do this. I tried it with google cloud console. Is there a way to set timeout to websocket in .yaml file.</p>

<p>This is my ingress controller.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: load-balancer
spec:
  rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: dash-board
          servicePort: 2020
      - path: /auth/*
        backend:
          serviceName: auth-service
          servicePort: 1111
      - path: /filter-service/*
        backend:
          serviceName: filter
          servicePort: 8081
      - path: /data-service/*
        backend:
          serviceName: data-service
          servicePort: 8090
      - path: /streaming/*
        backend:
          serviceName: streaming
          servicePort: 8080 
</code></pre>

<p>"streaming" is the websocket service.</p>

<p>Client is javascript.</p>

<pre><code>$scope.webSocket=new WebSocket("ws://"+ location.host"+"/streaming/test");
 $scope.webSocket.onopen = function () {
       console.log("CONNECTED");
 };
</code></pre>

<p>Thanks in advance.</p>

<p>Based on the <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features#timeout" rel="nofollow noreferrer">docs</a>, you need to setup a BackendConfig as follows:</p>
<pre><code>apiVersion: cloud.google.com/v1beta1
kind: BackendConfig
metadata:
  name: my-backendconfig
spec:
  timeoutSec: &lt;YOUR_DESIRED_TIMEOUT&gt;
</code></pre>
<p>And then add this config to your Service annotation, for example:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    app: web-server
  name: web-server
  annotations:
    cloud.google.com/backend-config: '{&quot;default&quot;: &quot;my-backendconfig&quot;}'
</code></pre>
