“端点请求超时”错误即将发生

时间:2017-07-12 05:34:52

标签: spring aws-lambda

我有一个spring应用程序,当我从API网关触发lambda函数时,“Endpoint request timed out”错误即将发生。代码如下所示。

public class LambdaHandler implements RequestHandler<AwsProxyRequest, AwsProxyResponse> {
     private static final Logger LOG = LoggerFactory.getLogger(LambdaHandler.class);

        private SpringLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;

    @Override
    public AwsProxyResponse handleRequest(AwsProxyRequest awsProxyRequest, Context context) {
        try {
            handler = SpringLambdaContainerHandler.getAwsProxyHandler(MvcConfig.class);

        } catch (ContainerInitializationException e) {
            LOG.warn("Unable to create handler", e);
            return null;
        }

        return handler.proxy(awsProxyRequest, context);
    }
}

MvcConfig类是: -

@SpringBootApplication
@EnableWebMvc
@Configuration
@ComponentScan(basePackages = {"com.joeyvmason.serverless.spring"})
public class MvcConfig {
}

和HelloController类是: -

@RestController
@RequestMapping("/hello")
public class HelloController {
        @RequestMapping(method = RequestMethod.GET)
        public String hello(@PathVariable String id) {
                return "Hello World!";
        }
}

提前感谢您的帮助

0 个答案:

没有答案