Configuration Quickstart
In this quickstart we'll set up Kanalo to send messages from clients to the server we set up in the Server Quickstart.
1. The configuration file
Kanalo uses a configuration file to properly route messages to the correct hook handlers. For the echo server set up in the Server Quickstart, we only have a single endpoint, and all messages are sent to it. The file will look like so:
version: '1.0.0'
hooks:
MESSAGE:
Echo:
rule: '*'
urls: <server endpoint URL>
apps:
echo:
clientId: echo
name: Echo App
type: native
tokenLocation: http_header
wsTimeout: 15000
authConfig:
type: static
key: <some key>
The file above defines two things for us:
A definition of a hook named 'Echo'. Every message sent to Kanalo will fire this hook due to the rule being
'*'
(catch-all), and it will send the message to<server endpoint URL>
, the URL of the server we set up in the Server Quickstart. (The'*'
rule is included here as a demonstration. Omitting therule
key entirely will also make the hook catch-all).A definition of an app ("Echo App"). This defines a way the client will connect and some attributes for handling the WebSocket and authentication (static authentication using
<some key>
as the authentication string).
To start, you can use the template above and just change the URL and key. The full structure of the config file and available options and config values are documented here.
2. Deploying using the kanalo.yaml file
2.1 Via the dashboard
Simply copy and paste the file above into the editor in the dashboard and update the URL and key. Then click "Save".
3. Verify
At this point, you should be able to contact your echo server using wscat (if you have it installed) or using wscat.dev at your tenant's address:
wscat -c "wss://<tenant>.on.kanalo.dev/echo?token=<some key>"
and confirm that everything is working by typing a message to be echoed back.
With Kanalo configured, you're now ready to continue on to building a client application.