Laravel websocket on kubernetes - some calls are being dropped

11/5/2021

We have an application that uses laravel websocket package and is deployed on kubernetes with two running pods. When a call is made, only clients who are connected to that pod get the message and others being dropped out. We tried using redis as a solution for this. Upgraded laravel-websocket package to version 2.0(beta) and set the following settings.

BROADCAST_DRIVER=pusher
PUSHER_APP_ID=12345
PUSHER_APP_KEY=12345
PUSHER_APP_SECRET=12345
PUSHER_APP_CLUSTER=mt1

WEBSOCKETS_REPLICATION_MODE=redis
LARAVEL_WEBSOCKETS_PATH=api/ws
LARAVEL_WEBSOCKETS_DOMAIN=domain.com
LARAVEL_WEBSOCKETS_PORT=443

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

Still the problem is messages are not being sent to all users but only to who are connected to the sender's pod.

Our redis is withing the k8 cluster and both pods are connected to the same redis. When we monior redis, we can see that all messages are coming.

Can anyone please let me know if I am missing anything here.

Thanks!

-- shakpit
kubernetes
laravel
laravel-websockets
redis
websocket

0 Answers