[ Bug]: PUSHER_HOST behaves differently between client and server
Describe the bug
While fixing issues with the soketi instance in our deployment, I realized that the handling of PUSHER_HOST is inconsistent between client and server, leading to... an interesting divergence.
For example, when PUSHER_HOST is set exactly to /websocket, the client will properly pick this up as a relative path:
// in: util/hooks/usePusher
// check if the pusher host is relative (e.g. /websocket)
const isRelative =
configData.PUSHER_HOST && configData.PUSHER_HOST.startsWith("/");On the backend, however:
// in: keep/api/core/dependencies.py
def get_pusher_client() -> Pusher | None:
logger.debug("Getting pusher client")
pusher_disabled = os.environ.get("PUSHER_DISABLED", "false") == "true"
pusher_host = os.environ.get("PUSHER_HOST")
// (...)
pusher = Pusher(
host=pusher_host,
port=(
int(os.environ.get("PUSHER_PORT"))
if os.environ.get("PUSHER_PORT")
else None
),
app_id=pusher_app_id,
key=pusher_app_key,
secret=pusher_app_secret,
ssl=pusher_use_ssl,
cluster=os.environ.get("PUSHER_CLUSTER"),
)This means that both will handle the supplied host entirely differently depending on what is being specified.
I solved this here by supplying two different PUSHER_HOST variables to the frontend and backend respectively.
To Reproduce
Set the PUSHER_HOST variable to something like /websocket or even soketi-svc/websocket (host + path) - wether you enable or disable SSL makes no difference.
The backend will shatter against the wall of an invalid URL (it will resolve it to https:///websocket:443 for instance) but the frontend will be completely fine as it will just pick this up as a relative path.
When setting a host+path combination, both of them fail.
Expected behavior
I expected the backend and frontend to be able to parse the same value. However, that also actually does not make sense; because the external URI is likely different than the internal one. The external URI will reference to the endpoint managed by a reverse proxy, whilst the other will likely reference an internal container address - taking your Docker Compose for example, that would be keep-websocket.
If I may, clearly define different values: PUSHER_HOST_PUBLIC and PUSHER_HOST_PRIVATE. This immediately and cleanly differenciates between both. You can use the current PUSHER_HOST as a fallback for simplicity to avoid breaking changes.
Screenshots n/a
Additional context Got none. But I can show you how I am currently handling the config:
apiVersion: v1
kind: ConfigMap
metadata:
name: soketi-cm
namespace: keep
data:
PUSHER_DISABLED: "false"
PUSHER_APP_ID: "1"
PUSHER_APP_KEY: "keephq"
PUSHER_APP_SECRET: "keephq"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: soketi-host-int-cm
namespace: keep
data:
PUSHER_HOST: "websocket-svc"
PUSHER_PORT: "80"
PUSHER_USE_SSL: "false"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: soketi-host-ext-cm
namespace: keep
data:
PUSHER_HOST: "/websocket"
#PUSHER_PORT: "443"
PUSHER_USE_SSL: "true"Source: keephq/keep