在本教程.Net 6之后,我正在使用https://www.gokhan-gokalp.com/en/building-microservices-by-using-dapr-and-net-with-minimum-effort-01/ 6使用Dapr和状态管理做一个小项目。但有一个例外,我不知道如何处理。请告诉我,任何想法我都会非常感激的。
当我调用这个方法

像这样抛出一个异常
Dapr.DaprException: 'State operation failed: the Dapr endpoint indicated a failure. See InnerException for details.'
Inner Exception
RpcException: Status(StatusCode="Unavailable", Detail="Error connecting to subchannel.", DebugException="System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at Grpc.Net.Client.Balancer.Internal.SocketConnectivitySubchannelTransport.TryConnectAsync(CancellationToken cancellationToken)")下面是运行dapr的命令
start dapr run --app-id shoppingcartapi --app-port 5001 --dapr-http-port 50001 --components-path "./components" -- dotnet run --project "./Dapr.ShoppingCart/Dapr.ShoppingCart.csproj"
start dapr run --app-id recommendationapi --app-port 6000 --dapr-http-port 50002 --components-path "./components" -- dotnet run --project "./Dapr.Recommendation/Dapr.Recommendation.csproj"这是pubsub文件
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: eventbus
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
- name: redisPassword
value: ""和statestore yaml文件
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: redisstore
spec:
type: state.redis
metadata:
- name: redisHost
value: localhost:6379
- name: redisPassword
value: ""
- name: actorStateStore
value: "true"发布于 2022-12-02 08:07:19
在我的Program.cs文件中,我忘记添加这个管道app.MapActorsHandlers();。加上这个,问题就解决了。
https://stackoverflow.com/questions/74544801
复制相似问题