2

I am using AWS - ECS service and I have 5 running tasks on the cluster that has initiated as awsvpc network mode.

The problem is that the task is supposed to send request to Twilio for the SMS code but the request to Twilio is being timed out.

  const twilioClient = require('twilio')(accountSid, authToken)
  try {
    await twilioClient.messages.create({
      body: `${code}`,
      from: phoneNumber,
      to: userInput.phone
    })
  } catch (err) {
    console.log('Twilio Error: ', err)
    return false
  }

The error below shows the error I have logged on CloudWatch.

Twilio Error: { 
Error: ETIMEDOUT
at Timeout._onTimeout (/srv/node_modules/request/request.js:849:19)
ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10) code: 'ETIMEDOUT', connect: true
}

The problem is that the same code works in case of default network mode for Task on AWS ECS.

I am using EC2 mode, not Fargate mode. Looking forward to the right help on this. Cheers.

Cool Eagle
  • 1,826
  • 3
  • 11
  • 16
  • What does the security group for the task look like? – ydaetskcoR Oct 23 '19 at 15:20
  • For now, I have let it accept all the ports(0-65535) from Anywhere in `Inbound Rules` and let it allow sending via all the ports(0-65536) to Anywhere in `Outbound Rules`. – Cool Eagle Oct 23 '19 at 15:29
  • 2
    It might be worth editing your question to include the output of `aws ecs describe-services --cluster CLUSTER_NAME --services SERVICE_NAME --query 'services[0].networkConfiguration'`. Also the output of `aws ec2 describe-security-groups --group-ids SECURITY_GROUP_ID` and `aws ec2 describe-route-tables` so it's possible to see all the network bits around your ECS service. Basically I'd be looking to see if the tasks have a route to the internet (via an IGW or public IPs) and if the security group allows it. There's also the possibility for NACLs to be in the way if you use those. – ydaetskcoR Oct 23 '19 at 15:39

0 Answers0