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

Mediator Stuck and isn't Updating (sending/receiving messages to mobile agent) #190

Closed x0axz closed 3 years ago

x0axz commented 3 years ago

2 Months ago, updated the Hyperledger.Aries.Routing.Edge to 1.6.1 from 1.4.0 and last week I noticed that we were getting an error in Presentation Proof, used the older version of agents and were still getting that same error. Noticed, that mediator got stuck and wasn't updating (after every 10 seconds, it route messages to mobile agent from issuer/verifier agent).

Now, using 1.4.0 again and Connections are most of time stuck in Negotiating, Credentials in Requested state e.t.c, and all these issues because of the reason that Mediator stuck and isn't routing messages.

I only noticed this error in mediator logs few times.

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unexpected end of request content.
   at Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException.Throw(RequestRejectionReason reason)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.ReadAsyncInternal(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 buffer, CancellationToken cancellationToken)
   at System.IO.StreamReader.ReadBufferAsync(CancellationToken cancellationToken)
   at System.IO.StreamReader.ReadToEndAsyncInternal()
   at Hyperledger.Aries.AspNetCore.AgentMiddleware.Invoke(HttpContext aHttpContext, IAgentProvider aAgentProvider)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
x0axz commented 3 years ago

Solved the Problem!!!

In App.xml.cs, there is a function OnStart(), where the mediator timer is set to enabled. What I was doing wrong was, I put the statement (timer.Enabled = true;) inside the else statement, which is wrong. It should be outside of curly brackets because It has to be enabled no matter which condition become true.

protected override async void OnStart()
{
    if (Preferences.Get(AppConstant.LocalWalletProvisioned, false))
    {    }
    else
    {    }

    timer.Enabled = true;
}