Client network socket disconnected before secure TLS connection was established aws lambda nodejs

Viewed 778

--> I have a basic set up of lambda function with eventBridge.this function is invoked after every 2 minute. There I have tournaments.txt file which has 35 tournaments ID and for each tournament ID I am fetching data from an api.
--> Then I am saving those fetched data to database using another serverless routes. Now in the cloudwatch log, my lambda function is giving error attached as screenshot below enter image description here

my lambda function code

const axios = require("axios");
const fs = require("fs");

const writeResult = async (id) => {
  console.log(id);
  try {
    const res = await axios.get(`${BASE_URL}/${id}.xml?json=1`);
    if (res) {
    const matches = res?.data?.commentaries?.tournament?.match;
      if (Array.isArray(matches)) {
        await Promise.all(
          matches.map(async (m) => {
            try {
              await axios.post(
                "https:example.com//route1",
                m
              );
              await axios.post(
                "https:example.com//route2",
                m
              );
              await axios.post(
                "https:example.com//route3",
                m
              );
              await axios.post(
                "https:example.com//route4",
                m
              );
              await axios.post(
                "https:example.com//route5",
                m
              );
              await axios.post(
                "https:example.com//route6",
                m
              );
            } catch (error) {
              console.log(error.message);
            }
          })
        );
      } 
  } catch (error) {
    console.log(error.message);
  }
};
exports.handler = async () => {
  const ids = fs
    .readFileSync("tournaments.txt", "utf-8")
    .replace(/\r/g, "")
    .trim()
    .split("\n");

  Promise.all(
    ids.map((id) => {
      writeResult(id);
    })
  );
  
  return "finally done";
};


What is the probable issue here? I've done some research but did not find any helpful solution.

0 Answers
Related