dotnet-sdk icon indicating copy to clipboard operation
dotnet-sdk copied to clipboard

Dapr.DaprApiException: the state store is not configured to use the actor runtime

Open Namohar opened this issue 3 years ago • 5 comments

Ask your question here

While Running with dapr Actor in c#, below error is occurring

Dapr.DaprApiException: the state store is not configured to use the actor runtime. Have you set the - name: actorStateStore value: "true" in your state store component file? at Dapr.Actors.DaprHttpInteractor.SendAsyncHandleUnsuccessfulResponse(Func1 requestFunc, String relativeUri, CancellationToken cancellationToken) at Dapr.Actors.DaprHttpInteractor.SendAsync(Func1 requestFunc, String relativeUri, CancellationToken cancellationToken) at Dapr.Actors.DaprHttpInteractor.InvokeActorMethodWithRemotingAsync(ActorMessageSerializersManager serializersManager, IActorRequestMessage remotingRequestRequestMessage, CancellationToken cancellationToken) at Dapr.Actors.Communication.Client.ActorRemotingClient.InvokeAsync(IActorRequestMessage remotingRequestMessage, CancellationToken cancellationToken) at Dapr.Actors.Client.ActorProxy.InvokeMethodAsync(Int32 interfaceId, Int32 methodId, String methodName, IActorRequestMessageBody requestMsgBodyValue, CancellationToken cancellationToken) at DaprActorPOC.Controllers.WeatherForecastController.GetAsync() in C:\Users\namohar.m\source\repos\Ex-1\DaprActorPOC\DaprActorPOC\Controllers\WeatherForecastController.cs:line 60 at lambda_method5(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Namohar avatar Aug 26 '22 01:08 Namohar

Hello I am having the same issue. I have built the example in Docker and using the runtime and I get this same error. I have this set to true in the state store as stated in the error in my docker components folder in the yaml.

"Have you set the - name: actorStateStore value: "true" in your state store component file?"

tomfanara avatar Aug 29 '22 01:08 tomfanara

yes, apiVersion: dapr.io/v1alpha1 kind: Component metadata: name: statestore spec: type: state.redis metadata:

  • name: redisHost value: localhost:6379
  • name: redisPassword value: ""
  • name: actorStateStore value: "true"

Namohar avatar Aug 29 '22 03:08 Namohar

When you run Dapr, do you see a log like:

INFO[0001] detected actor state store: statestore        app_id=testbedactor instance=Hals-MacBook-Pro.local scope=dapr.runtime type=log ver=edge

Or

INFO[0005] actor runtime started. actor idle timeout: 1h0m0s. actor scan interval: 30s  app_id=testbedactor instance=Hals-MacBook-Pro.local scope=dapr.runtime.actor type=log ver=edge

halspang avatar Aug 29 '22 16:08 halspang

image

detected actor state store

Namohar avatar Aug 30 '22 04:08 Namohar

@Namohar @halspang

I had this problem too when I was following the documentation here : https://v1-9.docs.dapr.io/developing-applications/sdks/dotnet/dotnet-actors/dotnet-actors-howto/

Make sure you are using version 1.8.0 of the SDK if you are using the 1.8.x runtime - the docs incorrectly use 1.0.0.

I then also went down a rabbit hole with trying to use the dapr VS Code extension so I could debug both the Actor and the Client at the same time.

After following this step here and then configuring launch.json and tasks.json as described here

Eventually I got it all working.

olitomlinson avatar Sep 26 '22 14:09 olitomlinson

@Namohar - Are you sure that your component was scoped to the appropriate apps? And did you see the next log line that I asked for?

halspang avatar Oct 31 '22 21:10 halspang

I ran into this same issue. You'll need to configure your docker-compose.yaml to include the following command arguments to your dapr sidecar:

"--placement-host-address", "host.docker.internal:6050"

Take a look at your placement instance running in Docker Desktop to confirm the port number there.

You'll also need to update your pubsub and statestore components' yaml files to point to host.docker.internal instead of localhost.

Example:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: pubsub
spec:
  type: pubsub.redis
  version: v1
  metadata:
  - name: redisHost
    value: host.docker.internal:6379
  - name: redisPassword
    value: ""
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: statestore
spec:
  type: state.redis
  version: v1
  metadata:
  - name: redisHost
    value: host.docker.internal:6379
  - name: redisPassword
    value: ""
  - name: actorStateStore
    value: "true"

This will correctly configure your docker compose managed instances to connect to your default dapr placement and redis instances created using dapr init on your dev machine.

The alternative is to spin up a dapr placement and redis instance inside your docker compose stack. The error is a bit misleading. The real issue is daprd is not able to communicate with either service inside the docker compose stack because it's a different network.

jsmith-kno2 avatar Jan 11 '23 17:01 jsmith-kno2