hyperledger-archives / aries-framework-dotnet

Aries Framework .NET for building multiplatform SSI services
https://wiki.hyperledger.org/display/aries
Apache License 2.0
84 stars 74 forks source link

DotNet Edge Agent unable to send BasicMessage to Aca-Py #173

Closed sahil-khanna closed 3 years ago

sahil-khanna commented 3 years ago

I'm trying to send a BasicMessage from the Xamarin Edge Agent to the Aca-Py Cloud Agent using the below code

Hyperledger.Aries.Features.BasicMessage.BasicMessage basicMessage = new()
{
    Content = "Some Text",
    SentTime = DateTime.UtcNow.ToString("s", CultureInfo.InvariantCulture)
};

IMessageService messageService = App.Container.Resolve<IMessageService>();
await messageService.SendAsync(AgentContext, basicMessage, Connection.Record);

The message is not received at the Aca-Py end

I also tried sending the message as below. However, I get the error as {"@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/notification/1.0/problem-report", "@id": "8b605a23-b58d-466d-bb7a-eb456bd48ac1", "~thread": {"thid": "59134bfd-7b2a-49ee-ac42-9a4c310c632b"}, "explain-ltxt": "Error deserializing message: BasicMessage schema validation failed"}

MessageContext messageContext = await messageService.SendReceiveAsync(AgentContext, basicMessage, Connection.Record);

The BasicMessageRecords aren't fetched with the below code on the Edge Agent indicating that the message isn't sent from Edge Agent to Aca-Py

List<BasicMessageRecord> basicMessageRecords = await walletRecordService.SearchAsync<BasicMessageRecord>(AgentContext.Wallet, SearchQuery.Equal(nameof(BasicMessageRecord.ConnectionId), ConnectionRecord.Id), null, int.MaxValue);

Note: The Xamarin Edge Agent is able to receive messages from Aca-Py without any issue

sahil-khanna commented 3 years ago

I discovered that BasicMessage can be sent as below

DateTime sentTime = DateTime.UtcNow;
BasicMessageRecord basicMessageRecord = new()
{
    Id = Guid.NewGuid().ToString(),
    Direction = MessageDirection.Outgoing,
    SentTime = sentTime,
    ConnectionId = Connection.Record.Id,
    Text = "text"
};

BasicMessage basicMessage = new()
{
    Content = "text",
    SentTime = sentTime.ToString("s", CultureInfo.InvariantCulture)
};

await walletRecordService.AddAsync(AgentContext.Wallet, basicMessageRecord);

IMessageService messageService = App.Container.Resolve<IMessageService>();
await messageService.SendAsync(AgentContext, basicMessage, Connection.Record);