Phoenix channel connector continues to close in a distributed cluster environment

I followed this series of articles to create a deployment on Google Cloud. Everything works as expected, except for the phoenix channels.

No server side errors. In the Javascript interface, I get the first ERROR channel and then the CLOSES socket on the interface when using channels. And this is endlessly repeated in the interval of 10-20 seconds.

CHANNEL ERROR!
SOCKET CLOSE!
CHANNEL ERROR!
SOCKET CLOSE!

From this code:

socket.connect()
socket.onError( e => console.log("SOCKET ERROR", e) )
socket.onClose( e => console.log("SOCKET CLOSE", e))
channel = socket.channel("note:" + noteId, {})
channel.onError( e => console.log("CHANNEL ERROR!", e) )
channel.onClose( e => console.log("CHANNEL CLOSED!", e) )

I need help to debug this and find out where this problem comes from. Please let me know if any part of the code is needed, and I will update the question with this code. It was a week. :(

Thank you so much!

(No problem when running locally)

: , , , phoenix.js heartbeat, .

UPDATE:

---- my-ingress.yaml ----
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    # ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: "gce"
    kubernetes.io/ingress.global-static-ip-name: my-ingress-ip
    kubernetes.io/tls-acme: "true"
spec:
  rules:
  - host: apiv2.example.com
    http:
      paths:
      - path: /*
        backend:
          serviceName: my-service-nodeport
          servicePort: 80
      - path: /.well-known/acme-challenge
        backend:
          serviceName: kube-lego-gce
          servicePort: 8080
  tls:
  - secretName: my-secret-tls-7
    hosts:
    - apiv2.example.com

, kube-lego .

UPDATE: ( dev, ). ... . , .

const HEARTBEAT_INTERVAL_MS = 5000
socket.onOpen(() => {
      clearInterval(this.heartbeatTimer);
      this.heartbeatTimer = setInterval(() => { 
        return socket.push({ 
          topic: "phoenix", 
          event: "heartbeat", 
          payload: {}, 
          ref: socket.makeRef(), 
        }); 
      }, 
        HEARTBEAT_INTERVAL_MS
      );
    })
+4

Source: https://habr.com/ru/post/1688272/


All Articles