在每天使用node.js上在特定时间发送whatsapp上的消息时发出问题

发布于 2025-01-28 16:56:14 字数 972 浏览 3 评论 0原文

我正在node.js上编写一个程序,该程序每天在特定时间发送WhatsApp模板。我使用了Node-Cron和SetInterval。当我在 https://id.heroku.com/login 要远程运行它不起作用。但是,当我在vscode上本地运行它时,它可以正常运行,我似乎无法弄清楚这个问题。

帮助您表示赞赏。

const express = require('express');
const webApp = express();

webApp.use(express.json());
const PORT = process.env.PORT;
function myFunc() {
    // console.log("Checking every 2 second")
    cron.schedule('15 16 * * *', () => {
        console.log("Checking every 2 second")
        sendDayTemplate();

    })
}
setTimeout(myFunc, 1000);

webApp.listen(PORT, () => {
    console.log(`Server is up and running at ${PORT}`);
});


heroku logs 渲染日志

I'm writing a program in Node.js which sends a WhatsApp template every day at a specific time. I used node-cron and setInterval. When I deployed the program on https://dashboard.render.com/# or https://id.heroku.com/login to run it remotely it doesn't work. but when I run it locally on VSCode it works fine, I can't seem to figure out the issue.

Help is appreciated.

const express = require('express');
const webApp = express();

webApp.use(express.json());
const PORT = process.env.PORT;
function myFunc() {
    // console.log("Checking every 2 second")
    cron.schedule('15 16 * * *', () => {
        console.log("Checking every 2 second")
        sendDayTemplate();

    })
}
setTimeout(myFunc, 1000);

webApp.listen(PORT, () => {
    console.log(`Server is up and running at ${PORT}`);
});


Heroku logs
Render logs

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文