KNoT Cloud WebSocket protocol adapter.
This service is part of the KNoT Cloud and requires a subset of its service to work. It is a websocket service that provides the API for registering and interacting with devices.
Configuration is made via a JSON file placed into config folder (see config package documentation for more info), but also it is possible to configure via environment variables. The parameters are:
PORTNumber Server port number. (Default: 80)MESHBLU_NAMESPACEString Meshblu's namespace on Redis. (Default: meshblu)MESHBLU_MESSAGES_NAMESPACEString Meshblu's messages namespace on Redis. (Default: messages)MESHBLU_REDIS_URIString URI of Redis server used by Meshblu.MESHBLU_FIREHOSE_REDIS_URIString URI of Redis server used by Meshblu Firehose.MESHBLU_CACHE_REDIS_URIString URI of Redis server used by Meshblu cache.MESHBLU_ALIAS_LOOKUP_SERVER_URIString Alias lookup service base URI.MESHBLU_ALIAS_SERVER_URIString Alias service base URI.MESHBLU_JOB_TIMEOUT_SECONDSNumber Job timeout in seconds (Default: 30)MESHBLU_JOB_LOG_SAMPLE_RATENumber Job sample rate (Default: 0)MESHBLU_REQUEST_QUEUE_NAMEString Meshblu's request queue name (Default: v2:request:queue)MESHBLU_RESPONSE_QUEUE_NAMEString Meshblu's response queue name (Default: v2:response:queue)LOGGER_LEVELString Log level (Default: debug/info)
Only change the MESHBLU_ parameters that have a default value if you know what you are doing.
First, install the dependencies:
npm i
Then:
npm run build
npm start
First, install the dependencies:
npm i
Then, start the server with auto-reload:
npm start:watch
Or, start the server in debug mode:
npm start:debug
A development container is specified at Dockerfile-dev. To use it, execute the following steps:
-
Build the image:
docker build . -f Dockerfile-dev -t knot-cloud-protocol-adapter-websocket-dev -
Create a file containing the configuration as environment variables.
-
Run the container:
docker run --env-file adapter.env -p 4000:80 -v `pwd`:/usr/src/app -ti knot-cloud-protocol-adapter-websocket-dev
The first argument to -v must be the root of this repository, so if you are running from another folder, replace `pwd` with the corresponding path.
This will start the server with auto-reload.
Containers built from the master branch and the published tags in this repository are available on DockerHub.
- Create a file containing the configuration as environment variables.
- Run the container:
docker run --env-file adapter.env -p 4000:80 -ti cesarbr/knot-cloud-protocol-adapter-websocket
To verify if the service is running properly, execute:
curl http://<hostname>:<port>/healthcheck