This sample is meant to demonstrate websockets with Apigee hybrid.
A sample websocket sample is included which responds with hello
. To install the server,
- kubectl 1.13 or higher
- docker 19.x or higher
- skaffold 1.1.0 or higher (optional)
- Build the docker image
- Deploy to a container register
- Modify the kubernetes manifest
- Deploy the server
kubectl apply -f websockets.yaml
This application can also be installed via skaffold. Modify the skaffold.yaml to set the appropriate project name.
skaffold run
When rerunning/installing the application, you may observe errors like this:
- Error from server (Invalid): error when applying patch:
...
...
`selector` does not match template `labels`
There is an open issue for this in the skaffold project.
Workaound: first run skaffold delete
and then skaffold run
An API Proxy is included which verifies an API Key before allowing the websocket connection.
- Apigee hybrid runtime
- GKE 1.13.x
- apigeecli v1.1 (optional)
- A GCP Service Account with pemrissions to create apis, products ,developers and apps.
./install-sample-apigee.sh {org-name} {env-name} {path-to-service-account.json}
A sample websocket sample is included which takes an input from the user and sends it to the server.
- go 1.13 or higher
- goreleaser v0.120.3 (optional)
Option 1: Download the binary from releases
Option 2: Build the binary manually using ./build.sh
Option 3: Build using goreleaser goreleaser --snapshot --skip-publish --rm-dist
NOTE: has been tested with v0.120.3
Input:
export API_KEY=xxx
export ENDPOINT=example.com
#use this flag to use ws:// vs. wss:// ; default is false
export TLS=false
./websocket-client
Output:
2019/12/21 21:27:12 connecting to ws://example.com/v1/ws?apikey=xxx
2019/12/21 21:27:13 recv: Replying to: '2019-12-21 21:27:13.403018 -0800 PST m=+1.010449853' with 'hello'
2019/12/21 21:27:14 recv: Replying to: '2019-12-21 21:27:14.400193 -0800 PST m=+2.007614408' with 'hello'
2019/12/21 21:27:15 recv: Replying to: '2019-12-21 21:27:15.403358 -0800 PST m=+3.010769896' with 'hello'
2019/12/21 21:27:16 recv: Replying to: '2019-12-21 21:27:16.400729 -0800 PST m=+4.008131894' with 'hello'