aries-framework-go
aries-framework-go copied to clipboard
Cannot Receive Invitation on Mobile
What I'm trying to do
I am trying to set up the Aries Go Framework on a mobile device. I built the .aar and included it in the Android project. I implemented the Provider
and Store
interfaces, the LoggerProvider
and Logger
interfaces, and now I am trying to receive an invitation.
This is how I create my agent:
val options = Options().apply {
useLocalAgent = true
storage = storeProvider
logger = loggerProvider
agentURL = mediatorAgentUrl
websocketURL = mediatorAgentWebsocketUrl
apiToken = mediatorAgentApiKey
label = localAgentName
}
agent = Ariesagent.new_(options)
Then, I am receiving an invitation by calling receiveInvitation()
on the DIDExchangeController
. The payload in the RequestEnvelope
looks as follows:
{
"@type":"https://didcomm.org/didexchange/1.0/invitation",
"@id":"96427dd3-bb44-441a-a24c-5bb7e46a9756",
"label":"Mediator",
"recipientKeys":["KEY"],
"serviceEndpoint":"ENDPOINT_URL"
}
As a response, I get no error, but a kind of empty result payload as an answer:
{
"state":"",
"created_at":"0001-01-01T00:00:00Z",
"updated_at":"0001-01-01T00:00:00Z",
"connection_id":"23914fe1-dc28-49ae-942e-309d76ee5191",
"request_id":"",
"my_did":""
}
The handler I registered prints the following information (so I guess the DIDExchangeController
at least receives some data and then does something with it):
2021-08-11 09:23:29.030 10055-11506/package D/MyHandler: received notification topic: didexchange_states
2021-08-11 09:23:29.040 10055-11506/package D/MyHandler: received notification message: {"id":"3ff0ebc7-880c-4b3f-9f47-ec046f0bdb31","topic":"didexchange_states","message":{"ProtocolName":"didexchange","Type":"post_state","StateID":"invited","Message":{"@id":"96427dd3-bb44-441a-a24c-5bb7e46a9756","@type":"https://didcomm.org/didexchange/1.0/invitation","label":"Mediator","recipientKeys":["KEY"],"serviceEndpoint":"SERVICE_ENDPOINT_URL"},"Properties":{"connectionID":"31f6968d-4056-4284-8d8e-197a2270aa61","invitationID":"96427dd3-bb44-441a-a24c-5bb7e46a9756"}}}
My logger prints the following:
aries-framework/did-exchange/service: receive inbound message : map[@id:96427dd3-bb44-441a-a24c-5bb7e46a9756 @type:https://didcomm.org/didexchange/1.0/invitation _internal_metadata:map[] label:Mediator recipientKeys:[KEY] serviceEndpoint:SERVICE_ENDPOINT_URL]
aries-framework/did-exchange/service: msgType=https://didcomm.org/didexchange/1.0/invitation thID=96427dd3-bb44-441a-a24c-5bb7e46a9756
aries-framework/did-exchange/service: retrieved current state [null] using nsThID [my_39363432376464332d626234342d343431612d613234632d356262376534366139373536e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855]
aries-framework/did-exchange/service: check if current state [null] can transition to [invited]
aries-framework/did-exchange/service: command=[didexchange] action=[handleInbound] [msgType=[https://didcomm.org/didexchange/1.0/invitation] msgID=[96427dd3-bb44-441a-a24c-5bb7e46a9756] connectionID=[1d8976ef-f977-446a-8312-aa99c3bbae4b]] msg=[success]
aries-framework/did-exchange/service: handling msg: &{Msg:map[@id:96427dd3-bb44-441a-a24c-5bb7e46a9756 @type:https://didcomm.org/didexchange/1.0/invitation _internal_metadata:map[] label:Mediator recipientKeys:[KEY] serviceEndpoint:SERVICE_ENDPOINT_URL] ThreadID:96427dd3-bb44-441a-a24c-5bb7e46a9756 Options:0x40004b63c0 NextStateName:invited ConnRecord:0x40004921e0 err:<nil>}
aries-framework/controller/did-exchange: command=[didexchange] action=[ReceiveInvitation] [invitationID=[96427dd3-bb44-441a-a24c-5bb7e46a9756] label=[Mediator] connectionID=[1d8976ef-f977-446a-8312-aa99c3bbae4b]] msg=[success]
aries-framework/did-exchange/service: sent pre event for state invited
aries-framework/out-of-band/service: input: {ProtocolName:didexchange Type:0 StateID:invited Msg:map[@id:96427dd3-bb44-441a-a24c-5bb7e46a9756 @type:https://didcomm.org/didexchange/1.0/invitation _internal_metadata:map[] label:Mediator recipientKeys:[KEY] serviceEndpoint:SERVICE_ENDPOINT_URL] Properties:0x400009a1e0}
aries-framework/did-exchange/service: finished execute state: invited
aries-framework/did-exchange/service: updated connection record &{ConnectionID:1d8976ef-f977-446a-8312-aa99c3bbae4b State:invited ThreadID:96427dd3-bb44-441a-a24c-5bb7e46a9756 ParentThreadID: TheirLabel:Mediator TheirDID: MyDID: ServiceEndPoint:SERVICE_ENDPOINT_URL RecipientKeys:[KEY] RoutingKeys:[] InvitationID:96427dd3-bb44-441a-a24c-5bb7e46a9756 InvitationDID: Implicit:false Namespace:my}
aries-framework/out-of-band/service: command=[out-of-band] action=[handleDIDEvent] [] errMsg=[ignored]
aries-framework/did-exchange/service: finish execute state action: 'invited'
aries-framework/did-exchange/service: sent post event for state invited
aries-framework/out-of-band/service: input: {ProtocolName:didexchange Type:1 StateID:invited Msg:map[@id:96427dd3-bb44-441a-a24c-5bb7e46a9756 @type:https://didcomm.org/didexchange/1.0/invitation _internal_metadata:map[] label:Mediator recipientKeys:[KEY] serviceEndpoint:SERVICE_ENDPOINT_URL] Properties:0x400049ea40}
aries-framework/did-exchange/service: halted execution before state=requested
aries-framework/out-of-band/service: command=[out-of-band] action=[handleDIDEvent] [] errMsg=[ignored]
aries-framework/did-exchange/service: command=[didexchange] action=[processMessage] [msgType=[https://didcomm.org/didexchange/1.0/invitation] msgID=[96427dd3-bb44-441a-a24c-5bb7e46a9756] connectionID=[1d8976ef-f977-446a-8312-aa99c3bbae4b]] msg=[success]
Is this correct at this point, or am I doing something wrong?
Neither my mediator agent, nor my Store
implementation is called at any point, which I find very strange. Shouldn't the agent store something? Also, why is my ResultEnvelope
empty, except for the connection_id
?
When I try to call acceptInvitation
using the above connection_id
, I receive an error telling me that some "data cannot be found". This is no surprise, since nothing was stored.
Am I missing some important configuration?
I am happy to supply more code should you need it.
My StoreProvider seems to be getting called. It creates a few stores. But the stores itself are never called. Can somebody confirm that setting your own store on mobile actually works?
I can confirm that the stores are being called.
However, in the particular case of receiving an invitation, no connection entry is created in the mobile store. Only the ProtocolStateStore seems to be called.
Why is that? Shouldn't a record be put into the mobile store as well (since the ProtocolStateStore exists only in memory)?
@Marco77577 I did not try to use the did exchange invitation but i got the connection to work with the out of band invitation.
From the documentation about mediators and edge agents without inbound capacity here, you have to go over websockets and allow the mediator to reuse these to return a response. This is necessary because an edge agent does not have a service endpoint.
So your agent's options should look like this:
val options = Options().apply {
useLocalAgent = true
storage = storeProvider
logger = loggerProvider
websocketURL = mediatorAgentWebsocketUrl
apiToken = mediatorAgentApiKey
transportReturnRoute = "all"
addOutboundTransport("ws")
label = localAgentName
}
agent = Ariesagent.new_(options)
Also be sure that mediatorAgentWebsocketUrl
is using the ws://
scheme.
Steps for a connection:
- Create an outofband invitation on the mediator (
outofband/create-invitation
). - Accept the invitation on the mobile agent with the method
acceptInvitation
from theOutOfBandController
(do not forget to addmy_label
to the received invitation). - On the mediator search for the requested connection id (e.g. search on
connections
) and accept the connection (connections/{connectionId}/accept-request
).
At the end you should see that the connection are completed on the mediator. But i did not find out how to find connections on the mobile agent yet.
Note: Be sure that all Aries component were uniformly compiled with or without the ACAPyInterop
tag.
question: Do you need to run a seperate daemon as mediator or is it enough to specify outbound? It's not enirely clear to me from the docs.
@mjolk You need an additional instance that acts as mediator for its public endpoint. A client device like a smartphone has no way to be connected to from the internet without the mediator intermediate.