Open dhmoon91 opened 1 year ago
Current Behavior
Conneciton timed out
Could not connect to the endpoint URL: "http://localhost:4006/2015-03-31/functions/slackService-dev-slack-service/invocations
Using postman for httpPort triggers local lambda correctly.
Sample Code
serverless.yml:
serverless.yml
service: slackService frameworkVersion: "3" provider: name: aws runtime: python3.8 stackName: ${opt:stage, 'dev'}-${self:service} deploymentBucket: name: ${opt:stage, 'dev'}-slack-service plugins: - serverless-python-requirements - serverless-deployment-bucket - serverless-latest-layer-version - serverless-offline functions: slack-service: handler: app.dispatcher.dispatcher events: - httpApi: "POST /slack-service" custom: pythonRequirements: dockerizePip: true serverless-offline: lambdaPort: 4006 httpPort: 4005
import json
def dispatcher(event, context): body = { "message": "Go Serverless v3.0! Your function executed successfully!", "input": event, } print("event") print(event) record = event["Records"][0]
response = {"statusCode": 200, "body": json.dumps(body)} return response
Output from running `sls offline start`:
Starting Offline at stage dev (us-east-1)
Offline [http for lambda] listening on http://localhost:4006 Function names exposed for local invocation by aws-sdk:
How I'm invoking it:
lambda_client = boto3.client( "lambda", region_name="local", aws_access_key_id="test", aws_secret_access_key="test2", endpoint_url="http://localhost:4006", ) lambda_client.invoke( FunctionName="slackService-dev-slack-service", Payload=(json.dumps({"eventId": event.id})), )
error msg:
Expected behavior/code
lambdaPort
Environment
serverless
serverless-offline
node.js
OS
optional, if you are using any of the following frameworks to invoke handlers
python
Possible Solution
Additional context/Screenshots
Did you find a solution for this? Have the same issue.
Same issue invoking lambda locally with boto3 inside docker container
Bug Report
Current Behavior
Conneciton timed out
when trying to invoke serverless-offline's lambda port.Could not connect to the endpoint URL: "http://localhost:4006/2015-03-31/functions/slackService-dev-slack-service/invocations
Using postman for httpPort triggers local lambda correctly.
Sample Code
serverless.yml
:def dispatcher(event, context): body = { "message": "Go Serverless v3.0! Your function executed successfully!", "input": event, } print("event") print(event) record = event["Records"][0]
Starting Offline at stage dev (us-east-1)
Offline [http for lambda] listening on http://localhost:4006 Function names exposed for local invocation by aws-sdk:
How I'm invoking it:
error msg:
Expected behavior/code
lambdaPort
when we want to invoke the function thru lambda client, but it's not working.Environment
serverless
version:serverless-offline
version: 12.0.4node.js
version: v16.14.0OS
: macOS 12.2.1optional, if you are using any of the following frameworks to invoke handlers
python
version: 3.8.9Possible Solution
Additional context/Screenshots