The Hyperledger Aries Cloud Agent - Python (ACA-Py) currently requires the ACA-Py controller to host several webhook endpoints in order to receive updates about the agents state as described here. This introduces a problem for mobile ACA-Py controller clients since it is not possible to expose such endpoints.
This repository aims to solve this problem 'the dirty way' by placing another component (called Webhook Receiver) in between ACA-Py and the Controller. The Webhook Receiver exposes the required webhook endpoints and records the requests made by ACA-Py. It also exposes an endpoint and websocket interface to get the recorded messages that the Controller call to process the messages.
Whenever a client opens a websocket connection, all in-memory messages that the client has missed so far will be send in the order they came in. (TODO -> create cli flag to make it optional) All new messages will be forwarded directly as long as the websocket connection lives. Whenever the connection is broken we'll start writing into memory again until the next time the client connects.
The docker-compose.yml
file contains a Alice - Faber test setup where both Alice and Faber have their own Webhook Receiver instance. Just run:
docker-compose build
docker-compose up -d
# and when you're done
docker-compose down
You can now connect to the various components through the following adresses:
Alice
Swagger UI: http://127.0.0.1:8002
Webhook Receiver (get new messages): http://127.0.0.1:8080/new_messages
Webhook Receiver (websocket): ws://127.0.0.1:8080/ws
Faber
Swagger UI: http://127.0.0.1:7002
Webhook Receiver (get new messages): http://127.0.0.1:7080/new_messages
Webhook Receiver (websocket): ws://127.0.0.1:7080/ws
If you prefer a single container version.
docker build -t webhook-receiver .
docker run -p 8080:8080 webhook-receiver
# make sure you have virtualenv
pip install virtualenv # or pip3 install virtualenv
# create a virtual environment
virtualenv --python=python3.7 ./webhook-receiver-env
# load it
source ./webhook-receiver-env/bin/activate
# install dependencies
pip install -r requirements.txt
usage: webhook-receiver [-h] [-w] [-l {CRITICAL,ERROR,WARNING,INFO,DEBUG}]
[--api-key API_KEY] [--host HOST] [--port PORT]
collects and cache's aca-py webhook calls until requested by controller.
optional arguments:
-h, --help show this help message and exit
-w, --websocket when passed, it will expose a websocket interface at
ws://HOST:PORT/ws
-l {CRITICAL,ERROR,WARNING,INFO,DEBUG}, --log {CRITICAL,ERROR,WARNING,INFO,DEBUG}
the log level
--api-key API_KEY if passed, this will be used as the API key. (one will
be generated by default)
--host HOST, -H HOST
--port PORT, -p PORT
When you run the webhook-receiver
, it will print the following message:
INFO - no api-key provided, generating one..
INFO - log level: INFO
INFO - websocket enabled at: ws://0.0.0.0:8080/ws
INFO - API Key: 55c56521-df27-4284-a71b-04501cd49c5b
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
Copy th printed address (in this case http://0.0.0.0:8080
) and pass it to a ACA-Py instance as the --webhook-url
argument. All webhook requests made by ACA-Py will now be directed towards the webhook-receiver. Your Controller instance can now fetch the messages by calling http://0.0.0.0:8080/new-messages
or subscribe to the websocket interface at http://0.0.0.0:8080/ws
. Please note that both methods require the Authorization
request header to be set to the webhook-receivers API key (in this case 55c56521-df27-4284-a71b-04501cd49c5b
).