#Reverb, websocket in production doesn't work

12 messages · Page 1 of 1 (latest)

brisk cliff
#

Hello, I am back on this project and still blocked, I tried to add the ports to my deployment.yml :

          ports:
            - containerPort: 80
            - containerPort: 8080

and to my service.yml :

    - port: 8080
      name: websocket
      targetPort: 8080
      protocol: TCP

but if I try to start with :
php artisan reverb:start

I have this error :

In TcpServer.php line 184:

 Failed to listen on "tcp://0.0.0.0:8080": Address in use (EADDRINUSE)  

so I removed it, now I have :

/app # php artisan reverb:start

   INFO  Starting server on 0.0.0.0:8080 (api.springcard.net).

But how can I test the websocket with postman for example ?

neat crystal
#

You can make a socket request with postman and check it

brisk cliff
brisk cliff
#

I don't know what I can do, still have the same problem. The websocket is working perfectly in local but in production I can't access it.

#

The websocket seems to start well but can't access it via postman / vuejs / curl

#

For the deployment I have 4 yml files :
back-deployment.yml

back-ingress.yml (did I have to change something ?)

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: apispringcardnet
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/proxy-set-headers: |
      Upgrade: $http_upgrade
      Connection: "upgrade"
    nginx.ingress.kubernetes.io/enable-websocket: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-back"
spec:
  ingressClassName: nginx
  rules:
    - host: api.springcard.net
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: apispringcardnet
                port:
                  number: 80
  tls:
    - hosts:
        - api.springcard.net
      secretName: letsencrypt-back

back-service.yml (should I add the port 8080 ?)

apiVersion: v1
kind: Service
metadata:
  name: apispringcardnet
spec:
  selector:
    app: apispringcardnet
  ports:
    - port: 80
      name: http
      targetPort: 80
      protocol: TCP
    - port: 443
      name: https
      targetPort: 443
      protocol: TCP
neat crystal
#

Is the websocket accessible at the root path?

brisk cliff
#

You mean like this ?

soft spoke
#

You set REVERB_SERVER_PORT=8080, yet you connect to it without a port. You also don't have that exposed/forwarded to the reverb server?

brisk cliff
# soft spoke You set `REVERB_SERVER_PORT=8080`, yet you connect to it without a port. You als...

Ah! I thought I was supposed to connect to api.springcard.net since I have the following in my .env:

echo "REVERB_HOST=api.springcard.net" >> .env
echo "REVERB_PORT=443" >> .env
echo "REVERB_SERVER_HOST=0.0.0.0" >> .env
echo "REVERB_SERVER_PORT=8080" >> .env
echo "REVERB_SCHEME=https" >> .env

Is that not the case?

Should I be connecting to the server’s REVERB_SERVER_PORT=8080 instead? Or is there something I’m missing ?
And what do you mean by "exposed/forwarded" ?

soft spoke
#

You may want to read this section: https://laravel.com/docs/11.x/reverb#running-server
Regarding to your last question, your WS request come in on the kubernetes cluster. I'm not too familiar with k8s, but I'd assume you'd need to tell it where to look. For example, with a reverse proxy you'd set the proxy to listen on port 443 for WS requests, then forward those to your Reverb instance, which could be running on port 8080.

brisk cliff
#

Ok so, I tried to modify some yml:
back-ingress.yml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: apispringcardnet
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/proxy-set-headers: |
      Upgrade: $http_upgrade
      Connection: "upgrade"
    nginx.ingress.kubernetes.io/enable-websocket: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /
    cert-manager.io/cluster-issuer: "letsencrypt-back"
spec:
  ingressClassName: nginx
  rules:
    - host: api.springcard.net
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: apispringcardnet
                port:
                  number: 80
          - path: /app/THEREVERB_APP_KEY
            pathType: Prefix
            backend:
              service:
                name: apispringcardnet
                port:
                  number: 8080
  tls:
    - hosts:
        - api.springcard.net
      secretName: letsencrypt-back

back-service.yml

apiVersion: v1
kind: Service
metadata:
  name: apispringcardnet
spec:
  selector:
    app: apispringcardnet
  ports:
    - port: 80
      name: http
      targetPort: 80
      protocol: TCP
    - port: 443
      name: https
      targetPort: 443
      protocol: TCP
    - port: 8080
      name: websocket
      targetPort: 8080
      protocol: TCP

now when I start it and I try to access it with postman :
wss://api.springcard.net/app/THEREVERB_APP_KEY?protocol=7&client=js&version=8.4.0-rc2&flash=false
or

I have :
Status Code: 404 Not Found

if I stop it I have :
Status Code: 502 Bad Gateway