2

I tried to using Pinpoint services in my Lambda Function using Python Language. But I am facing time out error once Executed my function. Here is my Lambda Function source code.

import json
import boto3

client = boto3.client('pinpoint')


def trigger(event, context):
    print("---------1----------------")
    payload = {
      'TraceId': 'sadfasdf',
      'Context': {
        'string': 'string'
      }, 
      'MessageConfiguration': {
        'GCMMessage': {
          'RawContent': ""
        }
      },
      'TemplateConfiguration': {
        'PushTemplate': {
          'Name': 'coll-1-en'
        }
      }, 
      'Users': {
        "id": {
          "Substitutions":{
            "subject": ["string"],
            "id": ["120913"]
          }
        }
      }
    }
    try:
      print("---------2----------------")
      response = client.send_users_messages(
        ApplicationId='my_aws_pinpoint_services_project.id',
        SendUsersMessageRequest=payload
      )
      print("---------3----------------")
      data = response.read()
      print(data.decode("utf-8"))
      return response
    except Exception:
      return False

I am not sure what is the issue from my code. So I have inserted print("-------") to find out the error lines.

The codes didn't executed since response = client.send_users_messages( line. So I was sure the client.send_users_messages had an issue. But I am not sure what is wrong in this line. Pls help me to fix this issue. I attached the screenshot of the Test result.

enter image description here

rv.kvetch
  • 9,940
  • 3
  • 24
  • 53
  • 2
    It looks like you need to increase the timeout set on the lambda function (appears to be set to 6 seconds currently). While you're at it, I'd also increase the memory to see if that helps. – rv.kvetch Oct 27 '21 at 13:27
  • 2
    I increased the time to 30 sec and memory size to 256MB, but it's same. I think it doesn't related to the time out and memory size directly. @rv.kvetch – Javier Gallego Oct 27 '21 at 13:31
  • 1
    Pls let me know the correct reason instead of time or memory size issue, @rv.kvetch – Javier Gallego Oct 27 '21 at 13:38
  • 2
    I have no idea tbh, but I've upvoted the question just in case anyone else has an idea. – rv.kvetch Oct 27 '21 at 13:39

0 Answers0