问题描述
我在 C# 中有一个简单的 AWS lambda 和 netcoreapp3.1,它尝试使用 gRPC 客户端 (EventStore.Client.Grpc.Streams
) 将一些事件附加到 EventStoreDb 中的流中。
在本地,(在 AWS Lambda 之外)我可以针对我的远程 EventStoreDb 正确使用相同的功能。部署为 AWS Lambda 时出现异常
{
"errorType": "RpcException","errorMessage": "Status(StatusCode=DeadlineExceeded,Detail=\"\")","stackTrace": [
"at EventStore.Client.Interceptors.TypedExceptionInterceptor.<AsyncclientStreamingCall>b__5_0[TRequest,TResponse](Task`1 t)","at System.Threading.Tasks.ContinuationResultTaskFromresultTask`2.InnerInvoke()","at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)","at System.Threading.ExecutionContext.RunFromThreadPooldispatchLoop(Thread threadPoolThread,ExecutionContext executionContext,ContextCallback callback,Object state)","--- End of stack trace from prevIoUs location where exception was thrown ---","at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot,Thread threadPoolThread)","at EventStore.Client.EventStoreClient.AppendToStreamInternal(AppendReq header,IEnumerable`1 eventData,EventStoreClientOperationoptions operationoptions,UserCredentials userCredentials,CancellationToken cancellationToken)","at EventStoreDb.LambdaSample.EventStore.Append(String streamName,Int32 aggregateVersion,IEnumerable`1 events,CancellationToken cancellationToken) in /mnt/c/src/issue-lambda-eventstore/src/EventStoreDb.LambdaSample/EventStore.cs:line 25","at EventStoreDb.LambdaSample.LambdaEntryPoint.FunctionHandler(APIGatewayProxyRequest request,ILambdaContext context) in /mnt/c/src/issue-lambda-eventstore/src/EventStoreDb.LambdaSample/LambdaEntryPoint.cs:line 52","at lambda_method(Closure,Stream,LambdaContextInternal )"
]
}
问题可以复现,我在此处添加了代码:https://gitlab.com/sunnyatticsoftware/sandbox/issue-lambda-eventstore 以及有关如何使用 AWS CLI 部署/运行 lambda 函数的说明。
请注意,这些说明所指的角色的 ARN 可能与您的情况不同,并且它使用的是我的 --profile diegosasw
,您必须在自己的 AWS CLI 中对其进行修改
public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest request,ILambdaContext context)
{
context.Logger.LogLine("Get Request\n");
context.Logger.LogLine("Storing sample events in event store");
var eventStoreClient = EventStoreClientFactory.Create(ConnectionString);
var serializationService = new SerializationService(SupportedTypes.Default);
var eventStore = new global::EventStoreDb.LambdaSample.EventStore(eventStoreClient,serializationService);
var foo = new Foo("First event");
var bar = new Bar( "Second event");
var events = new List<object> {foo,bar};
var id = Guid.NewGuid();
var streamName = $"SampleLambda-{id}";
// this is my own wrapper function
await eventStore.Append(streamName,events.Count,events,CancellationToken.None);
var response = new APIGatewayProxyResponse
{
StatusCode = (int)HttpStatusCode.OK,Body = "Events persisted successfully",Headers = new Dictionary<string,string> { { "Content-Type","text/plain" } }
};
return response;
}
更新:我也在此处创建了它:https://discuss.eventstore.com/t/grpc-core-rpcexception-deadlineexceeded-in-aws-lambda/3174
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)