dapr / dotnet-sdk

Dapr SDK for .NET
Apache License 2.0
1.11k stars 336 forks source link

Need help with .NET SDK Actors exception -- error invoke actor method: error finding address #1060

Closed georgestevens99 closed 1 year ago

georgestevens99 commented 1 year ago

I have based my code on .NET SDK examples, plus Dapr Docs examples, plus examples in Dapr for .NET Developers. But something very basic is wrong!

I would greatly appreciate any insight into how to move on from the below mix of output from 2 self hosted consoles, and snippets of the code. Note I am using Dapr 1.10.4 which I installed today, plus in the code all my Dapr nuget packages are 1.10. Thanks in advance!

3/19/23
The problem is: Dapr.DaprApiException: error invoke actor method: error finding address for actor type DataLatencyTestActor with id dltActor1.

My Exception From Feeds. Dapr ouput plus app logging to selfhosted console from the Feeds service that receives a pubsub message OK, then attempts to process it by calling the DataLatencyTestActor instance named dltActor1.

Below is the last retry of 5 or so attempts.

== APP == LatencyTests.OnLatencyTestEvent1() entered. eventMessage = "RunTest1 -- UiPayload=RunTest1 Sequence#=000000001."

== APP == info: ExploreDapr.Services.Feeds.Services.FeedsDispatcher[0] == APP == ** FeedsDispatcher: PubsubName=svs-pubsub-asbtopic, Subscr=latencyTestEvent1. Event payload string="RunTest1 -- UiPayload=RunTest1 Sequence#=000000001.".

== APP == LatencyTests.OnLatencyTestEvent1(): Calling SetDataAsync() on DataLatencyTestActor:dltActor1 time="2023-03-19T22:18:43.3060277-04:00" level=info msg="Error processing operation DaprBuiltInActorNotFoundRetries. Retrying in 1s…" app_id=feeds instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4

== APP == fail: ExploreDapr.Services.Feeds.Services.FeedsDispatcher[0] == APP == ** FeedsDispatcher: Exception when dispatching event for Topic=latencyTestEvent1. ex = Dapr.DaprApiException: error invoke actor method: error finding address for actor type DataLatencyTestActor with id dltActor1 == APP == at Dapr.Actors.DaprHttpInteractor.SendAsyncHandleUnsuccessfulResponse(Func1 requestFunc, String relativeUri, CancellationToken cancellationToken) == APP == at Dapr.Actors.DaprHttpInteractor.SendAsync(Func1 requestFunc, String relativeUri, CancellationToken cancellationToken) == APP == at Dapr.Actors.DaprHttpInteractor.InvokeActorMethodWithRemotingAsync(ActorMessageSerializersManager serializersManager, IActorRequestMessage remotingRequestRequestMessage, CancellationToken cancellationToken) == APP == at Dapr.Actors.Communication.Client.ActorRemotingClient.InvokeAsync(IActorRequestMessage remotingRequestMessage, CancellationToken cancellationToken) == APP == at Dapr.Actors.Client.ActorProxy.InvokeMethodAsync(Int32 interfaceId, Int32 methodId, String methodName, IActorRequestMessageBody requestMsgBodyValue, CancellationToken cancellationToken) == APP == at Dapr.Actors.Client.ActorProxy.ContinueWithResult[TRetval](Int32 interfaceId, Int32 methodId, Task1 task) == APP == at ExploreDapr.Services.Feeds.Services.LatencyTests.OnLatencyTestEvent1(String eventMessage) in C:\SWDev\DockerK8sDapr\MethodEw\Repos\Svs-ExploreDaprActors2\Services\ExploreDapr.Services.Feeds\Services\LatencyTests.cs:line 146 == APP == at ExploreDapr.Services.Feeds.Services.FeedsDispatcher.DispatchLatencyTestEvent1(String eventPayload) in C:\SWDev\DockerK8sDapr\MethodEw\Repos\Svs-ExploreDaprActors2\Services\ExploreDapr.Services.Feeds\Services\FeedsDispatcher.cs:line 198 == APP == at ExploreDapr.Services.Feeds.Services.FeedsDispatcher.OnTopicEvent(TopicEventRequest request, ServerCallContext context) in C:\SWDev\DockerK8sDapr\MethodEw\Repos\Svs-ExploreDaprActors2\Services\ExploreDapr.Services.Feeds\Services\FeedsDispatcher.cs:line 112 == APP == fail: Grpc.AspNetCore.Server.ServerCallHandler[6] == APP == Error when executing service method 'OnTopicEvent'. == APP == Dapr.DaprApiException: error invoke actor method: error finding address for actor type DataLatencyTestActor with id dltActor1 == APP == at Dapr.Actors.DaprHttpInteractor.SendAsyncHandleUnsuccessfulResponse(Func1 requestFunc, String relativeUri, CancellationToken cancellationToken) == APP == at Dapr.Actors.DaprHttpInteractor.SendAsync(Func1 requestFunc, String relativeUri, CancellationToken cancellationToken) time="2023-03-19T22:18:48.3621888-04:00" level=error msg="App handler returned an error for message c9db1befc1e44be48e9d9454cb5bccb5 on topic latencyTestEvent1: error returned from app while processing pub/sub event 3bd2dd99-6ca1-4d89-b334-0ea28553c5ea: rpc error: code = Unknown desc = Exception was thrown by handler." app_id=feeds component="svs-pubsub-asbtopic (pubsub.azure.servicebus/v1)" instance=A-GeorgeXPS1 scope=dapr.contrib type=log ver=1.10.4 == APP == at Dapr.Actors.DaprHttpInteractor.InvokeActorMethodWithRemotingAsync(ActorMessageSerializersManager serializersManager, IActorRequestMessage remotingRequestRequestMessage, CancellationToken cancellationToken) == APP == at Dapr.Actors.Communication.Client.ActorRemotingClient.InvokeAsync(IActorRequestMessage remotingRequestMessage, CancellationToken cancellationToken) == APP == at Dapr.Actors.Client.ActorProxy.InvokeMethodAsync(Int32 interfaceId, Int32 methodId, String methodName, IActorRequestMessageBody requestMsgBodyValue, CancellationToken cancellationToken) == APP == at Dapr.Actors.Client.ActorProxy.ContinueWithResult[TRetval](Int32 interfaceId, Int32 methodId, Task1 task) == APP == at ExploreDapr.Services.Feeds.Services.LatencyTests.OnLatencyTestEvent1(String eventMessage) in C:\SWDev\DockerK8sDapr\MethodEw\Repos\Svs-ExploreDaprActors2\Services\ExploreDapr.Services.Feeds\Services\LatencyTests.cs:line 146 == APP == at ExploreDapr.Services.Feeds.Services.FeedsDispatcher.DispatchLatencyTestEvent1(String eventPayload) in C:\SWDev\DockerK8sDapr\MethodEw\Repos\Svs-ExploreDaprActors2\Services\ExploreDapr.Services.Feeds\Services\FeedsDispatcher.cs:line 198 == APP == at ExploreDapr.Services.Feeds.Services.FeedsDispatcher.OnTopicEvent(TopicEventRequest request, ServerCallContext context) in C:\SWDev\DockerK8sDapr\MethodEw\Repos\Svs-ExploreDaprActors2\Services\ExploreDapr.Services.Feeds\Services\FeedsDispatcher.cs:line 112 == APP == at Grpc.Shared.Server.UnaryServerMethodInvoker3.AwaitInvoker(Task1 invokerTask, GrpcActivatorHandle1 serviceHandle) == APP == at Grpc.Shared.Server.UnaryServerMethodInvoker3.AwaitInvoker(Task1 invokerTask, GrpcActivatorHandle1 serviceHandle) == APP == at Grpc.AspNetCore.Server.Internal.CallHandlers.UnaryServerCallHandler3.HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext) == APP == at Grpc.AspNetCore.Server.Internal.CallHandlers.ServerCallHandlerBase3.g__AwaitHandleCall|8_0(HttpContextServerCallContext serverCallContext, Method`2 method, Task handleCall)

Dapr ouput to selfhosted console from the Actor Host service, StatisticsEngine, a .NET WebAPI with the standard Weatherforecast controller and an Actor folder containing the DataLatencyTestActor interface and actor implementation.

time="2023-03-19T22:16:12.9076278-04:00" level=info msg="application discovered on port 5277" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4 time="2023-03-19T22:16:12.9092641-04:00" level=info msg="actor runtime started. actor idle timeout: 1h0m0s. actor scan interval: 30s" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime.actor type=log ver=1.10.4 time="2023-03-19T22:16:12.9092641-04:00" level=info msg="configuring workflow engine with actors backend" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime.wfengine type=log ver=1.10.4 time="2023-03-19T22:16:12.9092641-04:00" level=info msg="Registering component for dapr workflow engine..." app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4 time="2023-03-19T22:16:12.909804-04:00" level=info msg="initializing Dapr workflow component" app_id=statisticsengine component="dapr (workflow.dapr/v1)" instance=A-GeorgeXPS1 scope=dapr.contrib type=log ver=1.10.4 time="2023-03-19T22:16:12.9417096-04:00" level=info msg="Error processing operation DaprBuiltInInitializationRetries. Retrying in 322.892684ms…" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4 time="2023-03-19T22:16:13.0477001-04:00" level=info msg="placement tables updated, version: 0" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime.actor.internal.placement type=log ver=1.10.4 time="2023-03-19T22:16:14.9227228-04:00" level=error msg="error getting topic list from app: rpc error: code = Unavailable desc = connection error: desc = \"error reading server preface: http2: frame too large\"" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4 time="2023-03-19T22:16:14.9227228-04:00" level=error msg="error occurred while beginning pubsub svs-pubsub-asbtopic: rpc error: code = Unavailable desc = connection error: desc = \"error reading server preface: http2: frame too large\"" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4 time="2023-03-19T22:16:14.9232853-04:00" level=info msg="Error processing operation DaprBuiltInInitializationRetries. Retrying in 452.267261ms…" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4 time="2023-03-19T22:16:16.8576684-04:00" level=error msg="error getting topic list from app: rpc error: code = Unavailable desc = connection error: desc = \"error reading server preface: http2: frame too large\"" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4 time="2023-03-19T22:16:16.8582044-04:00" level=error msg="error occurred while beginning pubsub svs-pubsub-redis: rpc error: code = Unavailable desc = connection error: desc = \"error reading server preface: http2: frame too large\"" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4 time="2023-03-19T22:16:16.8582044-04:00" level=info msg="dapr initialized. Status: Running. Init Elapsed 10298ms" app_id=statisticsengine instance=A-GeorgeXPS1 scope=dapr.runtime type=log ver=1.10.4

Program.cs from StatisticsEngine

public class Program
{
    public static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);

        // Add services to the container.
        builder.Services.AddControllers();
        builder.Services.AddActors(options =>
        {
            // Register ALL actor types hosted in this service.
            options.Actors.RegisterActor<DataLatencyTestActor>();
        });

        var app = builder.Build();

        // Configure the HTTP request pipeline.          
        app.UseRouting();

        // UseAuthorization() is generated code.  It is not in any of my actor code samples from Dapr Docs or
        // Dapr for .NET Developers.  Therefore I omit it.
        //app.UseAuthorization(); // UseAuthorization() must be between UseRouting() and UseEndpoints().

        app.UseEndpoints(endpoints =>
        {
            // Register actor handlers that interface with the Dapr runtime.
            endpoints.MapActorsHandlers();
        });
        // Commenting out above and doing this did not help. app.MapActorsHandlers();
        app.MapControllers();

        DisplayConfigSettings.DisplayKeyEnvironmentVariables();

        string thisNamespace = nameof(StatisticsEngine);
        string thisClass = nameof(Program);
        Console.WriteLine($"** {thisNamespace}.{thisClass}.cs calling app.Run();");

        app.Run();
}

The beginning of the implementation of the DataLatencyTestActor.cs

public class DataLatencyTestActor : Actor, IDataLatencyTestActor, IRemindable { public DataLatencyTestActor(ActorHost host) : base(host) { }

    // From https://docs.dapr.io/developing-applications/sdks/dotnet/dotnet-actors/dotnet-actors-howto/
    /// <summary>
    /// This method is called whenever an actor is activated.
    /// An actor is activated the first time any of its methods are invoked.
    /// </summary>
    protected override Task OnActivateAsync()
    {
        // Provides opportunity to perform some optional setup.
        Console.WriteLine($"Activating actor id: {Id}");
        return Task.CompletedTask;
    }
    .
    .
    .

Docker Desktop image

georgestevens99 commented 1 year ago

Monday 3/20/23 1018 EDT. I found the problem. My dapr run command was using app-protocol grpc. When I changed it to http all the problems went away! You can mark this issue solved, thanks.