0

我終於設法讓我的API進入可以將其上傳到AWS Lambda的狀態,然後每當我嘗試使用API​​網關對其進行測試時,都會收到以下錯誤消息。來自APIGatewayProxyFunction的空引用異常

{ 
     "errorType": "AggregateException", 
     "errorMessage": "One or more errors occurred. (Object reference not set to an instance of an object.)", 
     "stackTrace": [ 
     "at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)", 
     "at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)", 
     "at lambda_method(Closure , Stream , Stream , ContextInfo)" 
     ], 
     "cause": { 
     "errorType": "NullReferenceException", 
     "errorMessage": "Object reference not set to an instance of an object.", 
     "stackTrace": [ 
      "at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.MarshallRequest(InvokeFeatures features, APIGatewayProxyRequest apiGatewayRequest)", 
      "at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.<FunctionHandlerAsync>d__12.MoveNext()" 
     ] 
     } 
    } 

代碼:

public class LambdaEntryPoint : 
    Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction 
    { 
     protected override void Init(IWebHostBuilder builder) 
     { 
      try 
      { 
       builder 
        .UseContentRoot(Directory.GetCurrentDirectory()) 
        .UseStartup<Startup>() 
        .UseApiGateway(); 
      } 
      catch (Exception ex) 
      { 
       LambdaLogger.Log("Exception throw in LambdaEntryPoint: " + ex); 
      } 
     } 
    } 

我沒有從我的啓動或登錄LambdaEntryPoint任何異常。我對AWS真的很陌生,所以我不確定還有什麼要檢查的。

對此有何意見?

回答

0

這可能是同一個問題,從AWS有人跟在AWS github上回購了AWS .NET LAMBDA整合別人解決: https://github.com/aws/aws-lambda-dotnet/issues/168

+0

是的,我開了這個bug,以及。看起來它是AWS方面的東西,與代碼相關,但我還沒有能夠隔離它。 –