sam-cli本地调用错误:几秒钟后Docker超时

时间:2018-11-05 16:59:12

标签: python node.js amazon-web-services docker aws-lambda

我正在使用macOS High Sierra,并尝试运行sam-cli在本地调试我的lambda。 Lambda运行时是node.js8.10,SAM CLI,版本0.4.0

我使用以下命令

sam local invoke --event payload.json --debug-port 5858 [lambdaName] --profile [profileName]

调试器被调用,并且我能够在docker超时发生之前调试lambda代码一段时间。

`Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/sam", line 11, in <module>
    load_entry_point('aws-sam-cli==0.4.0', 'console_scripts', 'sam')()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/samcli/commands/local/invoke/cli.py", line 44, in cli
    docker_network, log_file, skip_pull_image, profile)  # pragma: no cover
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/samcli/commands/local/invoke/cli.py", line 76, in do_cli
    stderr=context.stderr)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/samcli/commands/local/lib/local_lambda.py", line 80, in invoke
    stdout=stdout, stderr=stderr)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/samcli/local/lambdafn/runtime.py", line 98, in invoke
    container.wait_for_logs(stdout=stdout, stderr=stderr)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/samcli/local/docker/container.py", line 187, in wait_for_logs
    self._write_container_output(logs_itr, stdout=stdout, stderr=stderr)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/samcli/local/docker/container.py", line 206, in _write_container_output
    for frame_type, data in output_itr:
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/samcli/local/docker/attach_api.py", line 98, in _read_socket
    payload_type, payload_size = _read_header(socket)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/samcli/local/docker/attach_api.py", line 170, in _read_header
    data = read_exactly(socket, 8)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/docker/utils/socket.py", line 47, in read_exactly
    next_data = read(socket, n - len(data))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/docker/utils/socket.py", line 31, in read
    return socket.recv(n)
socket.timeout: timed out`

这是我的山姆模板

`AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
    lambda Description

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
    Function:
        Timeout: 300

Resources:
    LambdaName:
        Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
        Properties:
            Handler: index.handler
            Runtime: nodejs8.10
            Environment:
                Variables:
                    NODE_TLS_REJECT_UNAUTHORIZED : "0"
                    BUCKET_NAME : "bucketName"
                    KEY_NAME : "file.json"
                    DYNAMO_RULE_TABLE : "TableName"
                NODE_ENV: "development" # NODE_ENV: "production"`

我找不到此问题的根本原因。

0 个答案:

没有答案