3
votes

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 (https://cloud.google.com/compute/docs/load-balancing/http/) says to change timeout value (timeoutSec in the API)

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.

This is my ingress controller.

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 

"streaming" is the websocket service.

Client is javascript.

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

Thanks in advance.

3

3 Answers

2
votes

Based on the docs, you need to setup a BackendConfig as follows:

apiVersion: cloud.google.com/v1beta1
kind: BackendConfig
metadata:
  name: my-backendconfig
spec:
  timeoutSec: <YOUR_DESIRED_TIMEOUT>

And then add this config to your Service annotation, for example:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: web-server
  name: web-server
  annotations:
    cloud.google.com/backend-config: '{"default": "my-backendconfig"}'
1
votes

There is a solution in here. https://cloud.google.com/compute/docs/reference/latest/backendServices

OR can increase time out using Google cloud console.

0
votes

Google Kubernetes Engine specific docs for configuring the timeout can be found here:

https://cloud.google.com/kubernetes-engine/docs/how-to/configure-backend-service