Skip to content

Latest commit

 

History

History
 
 

ws.reflect

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ws.reflect

Listens on ws port 8080 and will echo back whatever is sent to the server, broadcasting to all clients. Listens on wss port 9090 and will echo back whatever is sent to the server, broadcasting to all clients.

Requirements

  • bash, jq, nc
  • Kubernetes (e.g. Docker Desktop with Kubernetes enabled)
  • kubectl
  • helm 3.0+
  • wscat

Setup

The setup.sh script:

  • installs Zilla to the Kubernetes cluster with helm and waits for the pod to start up
  • starts port forwarding
./setup.sh

output:

+ ZILLA_CHART=oci://ghcr.io/aklivity/charts/zilla
+ VERSION=0.9.46
+ helm install zilla-ws-reflect oci://ghcr.io/aklivity/charts/zilla --version 0.9.46 --namespace zilla-ws-reflect --create-namespace --wait [...]
NAME: zilla-ws-reflect
LAST DEPLOYED: [...]
NAMESPACE: zilla-ws-reflect
STATUS: deployed
REVISION: 1
NOTES:
Zilla has been installed.
[...]
+ nc -z localhost 8080
+ kubectl port-forward --namespace zilla-ws-reflect service/zilla-ws-reflect 8080 9090
+ sleep 1
+ nc -z localhost 8080
Connection to localhost port 8080 [tcp/http-alt] succeeded!

Verify behavior

Connect each client first, then send Hello, one from first client, then send Hello, two from second client.

wscat -c ws://localhost:8080/ -s echo

output:

Connected (press CTRL+C to quit)
> Hello, one
< Hello, one
< Hello, two
wscat -c wss://localhost:9090/ --ca test-ca.crt -s echo

output:

Connected (press CTRL+C to quit)
< Hello, one
> Hello, two
< Hello, two

Teardown

The teardown.sh script stops port forwarding, uninstalls Zilla and deletes the namespace.

./teardown.sh

output:

+ pgrep kubectl
99999
+ killall kubectl
+ helm uninstall zilla-ws-reflect --namespace zilla-ws-reflect
release "zilla-ws-reflect" uninstalled
+ kubectl delete namespace zilla-ws-reflect
namespace "zilla-ws-reflect" deleted