openwallet-foundation/didcomm-mediator-service

Add SocketDock to Aries Mediator Service to make HA Mediator

Opened this issue · 0 comments

With the availability of SocketDock (https://github.com/hyperledger/aries-socketdock) to nicely take care of managing WebSocket connections with mobile agents, it would be helpful to implement a version of an Aries Mediator with SocketDock, ideally combined with Redis. Per the diagram for SocketDock:

image

Managing WebSocket connections becomes a matter of tracking SocketDock HTTP addresses for connected agents against the DIDComm address for the agent. Something like this (seems right -- but details left for the implementation):

  • When an agent is not connected to the mediator, queue up its messages in a "not connected" queue by DIDComm agent endpoint.
  • When an agent connects with the mediator (POST to messageuri), record the DIDComm/HTTP relationship, and send all queued message for the DIDComm agent to the HTTP address. Arriving messages while the connection is established are sent to the HTTP address.
  • When the DIDComm agent explicitly disconnects from SocketDock (POST to disconnecturi from image), remove the DIDComm agent endpoint/HTTP relationship, and push any unsent messages to the "not connected" queue.
  • When a post to the HTTP address for an agent (POST to externalhostandport) fails, assume the connection is lost, remove the DIDComm agent endpoint/HTTP relationship, and push any unsent messages to the "not connected" queue.

In implementing this, an effort should be made to make all components stateless so that a full HA (high availability) mediator can be deployed, with all components scalable. That implies a need to use Redis for the queuing and for cache consistency for the DIDComm/HTTP address tracking.

The redis work in this PR #78 will be helpful in implementing this.

The underlying mediator can be any component -- ACA-Py, AFJ, or even a "custom" DIDComm mediator.